Ejemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @param Guestbook $guestbook
  * @return redirect guestbook
  */
 public function store(CreateGuestbookRequest $request)
 {
     if (!Auth::check()) {
         $data = $request->only('name', 'email', 'text');
     } else {
         $data = $request->only('text');
         $data['user_id'] = 1;
     }
     $this->guestbookModel->create($data);
     return redirect()->route('guestbook');
 }
Ejemplo n.º 2
0
 public function storeGuestbook(CreateGuestbookRequest $request)
 {
     if (!Auth::check()) {
         $data = $request->only('name', 'email', 'text');
         $guestbook = new Guestbook($data);
     } else {
         $data = $request->only('text');
         $user = User::find(1);
         $guestbook = new Guestbook($data);
         $guestbook = $guestbook->user()->associate($user);
     }
     $guestbook->save();
     return redirect()->route('contacts');
 }