コード例 #1
0
ファイル: Post.php プロジェクト: libre-net-society/onelon
 public static function bump($post, $user_fp, $timestamp = false)
 {
     $timestamp = $timestamp ? $timestamp : date('Y-m-d H:i:s');
     if (Bump::where('post_id', '=', $post->id)->where('user_fp', '=', $user_fp)->first() == NULL && $post->user_fp != $user_fp) {
         $bump = Bump::create(['user_fp' => $user_fp, 'timestamp' => $timestamp, 'post_id' => $post->id]);
         $post->timestamps = false;
         $post->rating += 1;
         $post->save();
         return true;
     } else {
         App::abort(500, "You already bumped this post");
     }
 }