本文整理汇总了PHP中app\Activity::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::findOrFail方法的具体用法?PHP Activity::findOrFail怎么用?PHP Activity::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Activity
的用法示例。
在下文中一共展示了Activity::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
$router->bind('devices', function ($slug) {
return \App\Device::findBySlugOrFail($slug);
});
$router->bind('types', function ($slug) {
return \App\DeviceType::findBySlugOrFail($slug);
});
$router->bind('locations', function ($slug) {
return \App\DeviceLocation::findBySlugOrFail($slug);
});
$router->bind('admins', function ($slug) {
return \App\User::findBySlugOrFail($slug);
});
$router->bind('systemusers', function ($slug) {
return \App\User::findBySlugOrFail($slug);
});
$router->bind('activitylogs', function ($id) {
return \App\Activity::findOrFail($id);
});
$router->bind('userlogs', function ($id) {
return \App\UserLog::findOrFail($id);
});
$router->bind('authuser', function ($slug) {
return \App\User::findBySlugOrFail($slug);
});
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$actArray = POF::getItem(Activity::findOrFail($id)->guid);
$activity = Activity::findOrFail($id);
$singleActArray = ['title' => array_get($actArray, 'title', 'ei määritetty'), 'guid' => array_get($actArray, 'guid', 'ei määritetty'), 'content' => array_get($actArray, 'content', 'ei määritetty'), 'pakollisuus' => array_get($actArray, 'tags.pakollisuus.name', 'ei määritetty'), 'pakollisuusikoni' => array_get($actArray, 'tags.pakollisuus.0.icon', 'ei määritetty'), 'ryhmakoko' => array_get($actArray, 'tags.ryhmakoko.0.name', 'ei määritetty'), 'agegroup' => array_get($actArray, 'parents.1.title'), 'paikka' => array_get($actArray, 'tags.paikka.0.name', 'ei määritetty'), 'suoritus_kesto' => array_get($actArray, 'tags.suoritus_kesto.name', 'ei määritetty')];
return view('activity', compact('singleActArray', 'activity'));
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id, Request $request)
{
$activity = Activity::findOrFail($id);
$activity->update($request->all());
Session::flash('flash_message', 'Activity successfully updated!');
return redirect('activity');
}
示例4: remove
/**
* Removes activity from given event
*
* @param type $id
* @param type $activityId
*/
public function remove($id, $occId, Request $request)
{
$eventOccurrence = EventOccurrence::where('event_id', $id)->findOrFail($occId);
$activity = Activity::findOrFail($request->input('activityId'));
$eventOccurrence->activities()->detach($activity);
$eventOccurrence->save();
return redirect()->back();
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store($id, Request $request)
{
$this->validate($request, ['file' => 'required|mimes:jpg,jpeg,png']);
$activity = Activity::findOrFail($id);
$photo = $request->file('file');
ActivityPhoto::createPhoto($activity, $photo);
return 'Done';
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$activity = Activity::findOrFail($request->route()->parameter('activities'));
// Allows only activity that has no applicant and starts in the future
if (str_contains($activity->getApplicationStatus(), 'No application') && !$activity->datetime_start->isToday()) {
return $next($request);
}
return redirect('/activities');
}
示例7: show
public function show($id, $userId)
{
$user = User::findOrFail($userId);
$actArray = POF::getItem(Activity::findOrFail($id)->guid);
$activity = Activity::findOrFail($id);
$time = DB::table('activity_user')->where('user_id', $userId)->where('activity_id', $id)->first();
$singleActArray = ['title' => array_get($actArray, 'title', 'ei määritetty'), 'event_date' => $time->event_date, 'guid' => array_get($actArray, 'guid', 'ei määritetty'), 'content' => array_get($actArray, 'content', 'ei määritetty'), 'pakollisuus' => array_get($actArray, 'tags.pakollisuus.name', 'ei määritetty'), 'pakollisuusikoni' => array_get($actArray, 'tags.pakollisuus.0.icon', 'ei määritetty'), 'logo' => array_get($actArray, 'images.logo.url', 'https://learn.extension.org/assets/avatar_placeholder-4c003c71739be2ed78864bcd49550380.png'), 'ryhmakoko' => array_get($actArray, 'tags.ryhmakoko.0.name', 'ei määritetty'), 'agegroup' => array_get($actArray, 'parents.1.title'), 'paikka' => array_get($actArray, 'tags.paikka.0.name', 'ei määritetty'), 'suoritus_kesto' => array_get($actArray, 'tags.suoritus_kesto.name', 'ei määritetty')];
return view('activityShare', compact('singleActArray', 'activity', 'user'));
}
示例8: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$Activity = Activity::findOrFail($id);
if ($Activity->update($request->all())) {
return "Activity updated successfully.";
} else {
return $this->response->error('Activity could not be created.', 404);
}
}
示例9: update
public function update($id, CreateActivityRequest $request)
{
$input = $request->all();
$activity = Activity::findOrFail($id);
$activity->name = $input['name'];
$activity->description = $input['description'];
$activity->price = $input['price'];
$activity->duration = $input['duration'];
$activity->save();
return redirect('admin/activities');
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$activity = Activity::findOrFail($request->input('activity'));
$users = $request->input('user');
foreach ($users as $key => $value) {
if ($value) {
$user = User::findOrFail($key);
$user->activities()->attach($activity, ['marked_by_user_id' => '1', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), 'event_date' => Carbon::now()]);
}
}
}
示例11: retrieveElderyInformation
/**
* Retrieves information of elderly based on transport ID.
*
* @param \Illuminate\Http\Request $request
* @return JSON elderly or status
*/
public function retrieveElderyInformation(Request $request)
{
if ($request->get('transportId') == null) {
$status = ["Missing parameter"];
return response()->json(compact('status'));
} else {
$actID = $request->get('transportId');
$activity = Activity::findOrFail($actID);
$elderlyID = $activity->elderly_id;
//return response()->json(compact('elderlyID'));
$elderly = Elderly::with('languages')->findOrFail($elderlyID);
if ($elderly == null) {
$status = ["error"];
return response()->json(compact('status'));
} else {
return response()->json(compact('elderly'));
}
}
}
示例12: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
try {
$activity = Activity::findOrFail($id);
} catch (Exception $e) {
return back()->with('error', trans('default.activitynotfound'));
}
$locale = App::getLocale();
$title = $activity->{'name_' . $locale};
$lacquering = null;
if ($id == 2) {
try {
$lacquering = Activity::findOrFail(3);
} catch (Exception $e) {
return back()->with('error', trans('default.activitynotfound'));
}
}
return view('activities.show', compact('title', 'activity', 'locale', 'lacquering'));
}
示例13: store
public function store(Request $request)
{
$messages = ['name.required' => 'Tapahtumapohjalla tulee olla nimi', 'date.required' => 'Tapahtumapohjalla tulee olla aika', 'start.required' => 'Tapahtumapohjalla tulee olla aika', 'end.required' => 'Tapahtumapohjalla tulee olla aika', 'selectedAgeGroups.required' => 'Tapahtumapohjalla tulee olla ikäryhmä'];
$validator = Validator::make($request->all(), ['name' => 'required', 'date' => 'required_if:start,null', 'start' => 'required_if:date,null', 'end' => 'required_if:date,null', 'selectedAgeGroups' => 'required'], $messages);
if ($validator->fails()) {
return redirect('event_patterns/new')->withErrors($validator)->withInput();
}
$selected_activities = $request->input('selected_activity');
$event_pattern = new EventPattern();
$event_pattern->name = $request->input('name');
$event_pattern->ageGroups = $request->input('selectedAgeGroups');
if ($request->input('date') != NULL) {
$event_pattern->date = Carbon::createFromFormat('d.m.Y', $request->input('date'));
} else {
$event_pattern->date = Carbon::createFromFormat('d.m.Y', $request->input('start'));
$event_pattern->endDate = Carbon::createFromFormat('d.m.Y', $request->input('end'));
}
$event_pattern->save();
for ($i = 0; $i < count($selected_activities); $i++) {
$activity = Activity::findOrFail($selected_activities[$i]);
$event_pattern->activities()->attach($activity);
}
return redirect('/');
}
示例14: retrieveProgress
/**
* Get the progress of the given activity.
* Responds to requests to GET /activities/{id}/progress
*
* @param int $activityId the ID of the activity
* @return JSON
*/
public function retrieveProgress($activityId)
{
$activity = Activity::findOrFail($activityId);
return json_encode(['progress' => $activity->getProgress()]);
}
示例15: withdraw
/**
* Handles the withdrawal of activity from user.
*
* @param \Illuminate\Http\Request $request
* @return JSON array with Status
*/
public function withdraw(Request $request)
{
if ($request->get('volunteer_id') == null || $request->get('activity_id') == null) {
$status = ["Missing parameter"];
return response()->json(compact('status'));
} else {
$volunteer_id = $request->get('volunteer_id');
$activity_id = $request->get('activity_id');
$volunteer = Volunteer::findOrFail($volunteer_id);
$withdrawnActivity = Activity::findOrFail($activity_id);
$task = Task::where('volunteer_id', $volunteer_id)->where('activity_id', $activity_id)->update(['approval' => 'withdrawn']);
$mailingList = Staff::where('is_admin', 'TRUE')->lists('email')->toArray();
$status = ["Withdrawn from activity"];
Mail::send('emails.volunteer_withdraw', compact('volunteer', 'withdrawnActivity'), function ($message) use($mailingList) {
$message->subject('A volunteer has withdrawn from an activity');
$message->to($mailingList);
});
return response()->json(compact('status'));
}
}