Ejemplo n.º 1
0
 public function addFavorite(Request $request)
 {
     $post_id = intval($request->input('post_id'));
     if (!$post_id) {
         return;
     }
     $user = auth()->user();
     if ($user && $user->profile()) {
         $user->profile()->first()->addFavorite($post_id);
     } else {
         $profile = new Profile();
         return $profile->addFavoriteToCookie($request);
     }
 }