本文整理汇总了PHP中app\Group::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::findOrFail方法的具体用法?PHP Group::findOrFail怎么用?PHP Group::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Group
的用法示例。
在下文中一共展示了Group::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id, Request $request)
{
//$this->validate($request, ['name' => 'required']); // Uncomment and modify if needed.
$group = Group::findOrFail($id);
$group->update($request->all());
return redirect('admin/groups')->with('success', Lang::get('message.success.update'));
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
// we expect a url in the form /groups/{group_id}
if ($request->segment(1) == 'groups') {
if ($this->auth->guest()) {
$group = \App\Group::findOrFail($request->segment(2));
if ($group->isPublic()) {
return $next($request);
} else {
return redirect()->back()->with('message', trans('messages.not_allowed'));
}
} else {
$group = \App\Group::findOrFail($request->segment(2));
if ($group->isPublic()) {
return $next($request);
} elseif ($group->isMember()) {
return $next($request);
} elseif ($request->user()->isAdmin()) {
return $next($request);
// user is admin, and sees everything, fine (at least in sync with current policies for admins)
} else {
return redirect()->back()->with('message', trans('messages.not_allowed'));
}
}
} else {
return redirect()->back()->with('message', 'Are you in a group at all !? (url doesnt start with group/something). This is a bug');
}
}
示例3: store
public function store(Request $request)
{
$user = Auth::user();
if ($user->is('admin|groupadmin')) {
if ($request->hasFile('file')) {
$filename = $request->file('file')->getClientOriginalName();
if ($request->file('file')->move(sys_get_temp_dir(), $filename)) {
$path = sys_get_temp_dir() . '/' . $filename;
if ($request->has('user_id')) {
$target = User::findOrFail($request->input('user_id'));
$folder = $target->username;
$ret = redirect(url('admin/show/' . $target->id));
} else {
if ($request->has('group_id')) {
$group = Group::findOrFail($request->input('group_id'));
$folder = $group->name;
$ret = redirect(url('admin/groups/'));
}
}
if ($user->testAccess($folder)) {
Cloud::loadFile($path, $folder, $filename);
} else {
abort(403);
}
unlink($path);
}
}
return $ret;
} else {
abort(403);
}
}
示例4: destroy
public function destroy($groupId)
{
$group = Group::findOrFail($groupId);
$this->authorize('destroy', $group);
$group->delete();
return Redirect::to(route('group.index'))->with(['success_message' => 'Deleted!']);
}
示例5: store
/**
* @param $id
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store($id, \Illuminate\Http\Request $request)
{
$this->validate($request, ['name' => 'required|max:255', 'factor' => 'required']);
$group = Group::findOrFail($id);
$subject = new Subject(Request::all());
$group->subjects()->save($subject);
return redirect('groups');
}
示例6: remove
public function remove($id, Request $request)
{
$group = Group::findOrFail($id);
$user = User::findOrFail($request->input('userId'));
$group->users()->detach($user);
$group->save();
return redirect()->back();
}
示例7: update
public function update(GroupRequest $request, $id)
{
$group = \App\Group::findOrFail($id);
$group->update($request->all());
$group->swimmers()->sync($request->get('swimmer_list'));
\Session::flash('flash_message', 'Group has been updated.');
return redirect('groups');
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$group = Group::findOrFail($id);
if ($group) {
$group->delete();
return ['success' => true];
}
return ['success' => true];
}
示例9: destroy
/**
* Dissasociate the specified member resource from the group-event tuple.
*
* @param int $groupId
* @param int $memberId
* @return Response
*/
public function destroy($groupId, $memeberId)
{
$group = Group::findOrFail($groupId);
$member = $group->members()->findOrFail($memeberId);
if (Gate::denies('detach-member', $event, $group, $member)) {
abort(403);
}
$member->groups()->detach();
return response()->json("ok");
}
示例10: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
try {
$group = Group::findOrFail($id);
$group->delete();
$msg = "Delete successful!";
} catch (ModelNotFoundException $e) {
$msg = "Cannot delete record. Data not found.";
return redirect('group')->with('errMsg', $msg);
}
return redirect('group')->with('message', $msg);
}
示例11: letterSeach
public function letterSeach($name)
{
$users = User::where('name', 'like', '%' . $name . '%')->paginate();
foreach ($users as $u) {
$u->user_type_id = User::$typeses[$u->user_type_id];
if ($u->group_id == null) {
$u->group_id = "No pertenece a un grupo";
} else {
$group = Group::findOrFail($u->group_id);
$u->group_id = $group->name;
}
}
return view('admin.users.index', compact('users'));
}
示例12: addMany
public function addMany(Request $request)
{
$group = Group::findOrFail($request->input('group'));
$users = $group->users;
$activity = Activity::findOrFail($request->input('activityId'));
for ($i = 0; $i < count($users); $i++) {
$user = $users[$i];
$mark = $request->input($user->id);
if ($mark != NULL && self::userHasCompletedActivity($user, $activity) == false) {
$user->activities()->attach($activity, ['marked_by_user_id' => '1', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), 'event_date' => Carbon::now()]);
$user->save();
}
}
return redirect()->back();
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(CreateUserRequest $request)
{
$token = str_random(40);
$result = RegistrationLink::where('_token', $token)->first();
while ($result != null) {
$token = str_random(40);
$result = RegistrationLink::where('_token', $token)->first();
}
$request['_token'] = $token;
$request['valid_until'] .= ' 23:59:59';
$group = Group::findOrFail($request->group_id);
RegistrationLink::create($request->all());
Session::flash('flash_message', 'New registration link for "' . $group->name . '" group member has been created!<br>
Registration link is <a href="' . URL::to('admin/auth/register?_token=' . $request['_token']) . '">here</a>. You can send it to person you want to register as an administrator.');
Session::flash('flash_secondary', 'true');
Session::flash('flash_message_important', 'true');
return redirect('/admin/user/create');
}
示例14: saveGroupItem
public function saveGroupItem()
{
if (Request::has('entity') && Request::has('block') && Request::has('id')) {
$dataobj = Request::all();
if ($dataobj['entity'] == 'groupitem') {
try {
$groupitem = \App\Group::findOrFail($dataobj['id']);
$result = $groupitem->saveGroupItem($dataobj);
return ['status' => $result];
} catch (Exception $exception) {
return ['status' => 'Что-то пошло не так. ' . $exception->getMessage()];
}
} else {
return ['status' => 'Имя сохраняемой сущности не равно group (' . $dataobj['entity'] . ').'];
}
} else {
return ['status' => 'Не хватает параметров для сохранения.'];
}
}
示例15: destroy
/**
* Remove the specified member from storage.
*
* @param int $id The id of the member to delete
* @return Response
*/
public function destroy($id)
{
// Find and delete group
$group = Group::findOrFail($id);
$group->delete();
// Redirect
Session::flash('message', 'Η κοινοβουλευτική ομάδα διαγράφηκε με επιτυχία!');
return Redirect::to('groups');
}