本文整理汇总了PHP中app\Group::FindOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::FindOrFail方法的具体用法?PHP Group::FindOrFail怎么用?PHP Group::FindOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Group
的用法示例。
在下文中一共展示了Group::FindOrFail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public function destroy($id)
{
$group = \App\Group::FindOrFail($id);
$group->delete();
\Session::flash('flash_message', 'Group has been deleted.');
return redirect('groups');
}
示例2: storeNoRedirect
public function storeNoRedirect(Request $request)
{
$this->validate($request, ['name' => 'required|max:64', 'date' => 'required|date_format:d.m.Y|after:' . Carbon::now(), 'time' => 'required|date_format:H:i', 'place' => 'required|max:128']);
$event = new Event();
$event->name = $request->input('name');
$event->time = Carbon::createFromFormat('d.m.Y H:i', $request->input('date') . ' ' . $request->input('time'));
$event->place = $request->input('place');
$event->description = $request->input('description');
$event->group_id = $request->input('groupId');
$group = Group::FindOrFail($request->input('groupId'));
if (Gate::allows('manageForGroup', $group)) {
$days = collect($request->input('days'));
$date = Carbon::createFromFormat('d.m.Y', $request->input('date'));
$endDate = $date->copy();
$startDate = $date->copy();
$interval = $request->input('interval');
if ($request->input('repeat') != NULL) {
$ending = $request->input('ending');
$endDate = $ending == "afterYear" ? $endDate->addYear() : Carbon::createFromFormat('d.m.Y', $request->input('endDate'));
}
$event->endDate = $endDate;
$event->save();
do {
if ($days->contains($date->dayOfWeek) && $startDate->diffInWeeks($date) % $interval == 0 || $request->input('repeat') == NULL) {
$occurrence = new EventOccurrence();
$occurrence->event_id = $event->id;
$occurrence->date = $date;
$occurrence->save();
}
$date->addDay();
} while ($date < $endDate);
return redirect('activity_planning/planner');
} else {
return abort(403);
}
}