當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Post::Where方法代碼示例

本文整理匯總了PHP中app\Post::Where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Post::Where方法的具體用法?PHP Post::Where怎麽用?PHP Post::Where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Post的用法示例。


在下文中一共展示了Post::Where方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: status

 public function status($id)
 {
     $post = Post::where('id', $id)->first();
     if ($post['post_status'] == '0') {
         Post::Where('id', $id)->update(['post_status' => '1']);
         $status = 'active';
     } elseif ($post['post_status'] == '1') {
         Post::Where('id', $id)->update(['post_status' => '0']);
         $status = 'inactive';
     } else {
         return Response::json(['status' => 'error']);
     }
     return Response::json(['status' => $status]);
 }
開發者ID:kent62001,項目名稱:NTPU-career,代碼行數:14,代碼來源:PostController.php

示例2: function

Route::get('updateme/{id}', function ($id) {
    $response = ['posts' => App\Post::numberOfPostsSinceId($id)];
    return response()->json($response);
});
Route::get('dumper', function () {
    $getter = new \App\Getters\LebaneseBlogsGetter();
    $post = $getter->getList()[0];
    $post = (new \App\Transformers\LebaneseBlogsTransformer($post))->get();
    return $post;
});
Route::get('/{provider?}', function ($provider = null) {
    if ($provider) {
        // make sure the provider supported
        if (!in_array($provider, ['facebook', 'youtube', 'instagram', 'lebaneseblogs', 'twitter'])) {
            return response('page does not exist', 404);
        }
        // prepare posts. Cache if no cache
        $cacheRef = $provider . '__lastFiftyPosts';
        if (!\Cache::has($cacheRef)) {
            \Cache::put($cacheRef, \App\Post::Where('provider', $provider)->orderBy('date_published', 'DESC')->take(50)->get(), 3);
        }
        $posts = \Cache::get($cacheRef);
    } else {
        // prepare posts. Cache if no cache
        if (!\Cache::has('lastFiftyPosts')) {
            \Cache::put('lastFiftyPosts', \App\Post::orderBy('date_published', 'DESC')->take(50)->get(), 3);
        }
        $posts = \Cache::get('lastFiftyPosts');
    }
    return view('layout')->with(['posts' => $posts, 'provider' => $provider]);
});
開發者ID:aboustayyef,項目名稱:ysn,代碼行數:31,代碼來源:routes.php


注:本文中的app\Post::Where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。