Ejemplo n.º 1
0
 public function clubJoinRequestsReceived()
 {
     $bookclubs = $this->ownedclubs()->lists('id');
     $requests = \App\RequestBookClub::whereIn('book_club_id', $bookclubs)->get();
     return $requests;
 }
Ejemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function rejectJoinRequest($requestId)
 {
     $request = \App\RequestBookClub::findOrFail($requestId);
     if (!$request) {
         flash()->warning('Request already processed. ');
         return redirect()->back();
     }
     \App\Notification::where('request_id', $requestId)->first()->delete();
     $notification = $request->requestee->notifications()->create(['text' => 'Your request to join ' . $request->bookclub->name . ' was rejected or canceled.', 'url' => route('notifications.destroy', 1), 'is_read' => false]);
     $notification->url = route('notifications.destroy', $notification->id);
     $notification->save();
     // dd($notification);
     $request->delete();
     //generate Notification later extract and make use of events
     flash('Request Rejected succesfully.');
     return redirect()->back();
 }