Beispiel #1
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     //patikrinam ar zmogus dalyvauja pokalbyje i kuri bando atsakyti.
     $this->conversation = Conversation::findOrFail($this->input('conversation_id'));
     if ($this->conversation->users()->where('user_id', Auth::user()->id)->first()) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #2
0
 public function store(CreateMessage $request)
 {
     $user = Auth::user();
     $data = $request->all();
     $conversation = Conversation::findOrFail($data['conversation_id']);
     $message = Messenger::send($user, $conversation, $request->input('body'));
     if ($request->ajax()) {
         return 'OK';
     } else {
         return redirect()->back();
     }
 }