本文整理汇总了PHP中Notification::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::findOrFail方法的具体用法?PHP Notification::findOrFail怎么用?PHP Notification::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::findOrFail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dismiss
public function dismiss()
{
$user = Auth::user();
if (Input::has('all')) {
// dismiss all
$user->notifications()->update(array('dismissed' => true));
Session::flash('success', 'All notifications dismissed');
} else {
// dismiss single
$notifyId = Input::get('notification');
$notify = Notification::findOrFail($notifyId);
if ($notify->user_id !== $user->id) {
App::abort(403, 'That notification doesn\'t belong to you');
}
$notify->dismiss();
}
return Redirect::route('notifications');
}
示例2: update
/**
* Update the specified notification in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$notification = Notification::findOrFail($id);
$validator = Validator::make($data = Input::all(), Notification::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$notification->update($data);
// $alert = array(
// 'alert-success' => '<strong><i class="fa fa-check"></i></strong> Notificação atualizada!'
// );
$alert[] = ['class' => 'alert-success', 'message' => '<strong><i class="fa fa-check"></i></strong> Notificação atualizada!'];
Session::flash('alerts', $alert);
return Redirect::to(URL::previous());
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$notification = Notification::findOrFail($id);
$notification->delete();
return Redirect::back()->with('success', 'Notificatie succesvol verwijdererd');
}