コード例 #1
0
ファイル: Media.php プロジェクト: jubaedprince/instaappAPI
 public function skipped()
 {
     $user_id = User::getCurrentUserId();
     //Check if the media was already skipped by the user
     $skip = Skip::where('media_id', $this->id)->where('user_id', $user_id)->first();
     return (bool) $skip;
 }
コード例 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //Get the Media from given URL
     $media = Media::where('url', $request->url)->first();
     if (!$media) {
         return response()->json(['success' => false, 'message' => "No such media in our DB"]);
     }
     if (!$media->publishable) {
         return response()->json(['success' => false, 'message' => "You cannot skip this media"]);
     }
     return response()->json(['success' => true, 'message' => "Successfully skipped", 'skipped' => Skip::create(['user_id' => User::getCurrentUserId(), 'media_id' => $media->id])]);
 }