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


PHP Posts::where方法代碼示例

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


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

示例1: user_posts_all

 public function user_posts_all(Request $request)
 {
     $user = $request->user();
     $posts = Posts::where('author_id', $user->id)->orderBy('created_at', 'desc')->paginate(5);
     $title = $user->name;
     return view('home')->withPosts($posts)->withTitle($title);
 }
開發者ID:anmolarora,項目名稱:MyBlog_PHP,代碼行數:7,代碼來源:UserController.php

示例2:

@extends('qz.layout')

@section('title')
<?php 
$page = Pages::getPageByAlias($alias);
if (!$child) {
    $child = Pages::getFirstSubPage($page->id);
} else {
    $child = Pages::getPageByAlias($child);
}
$hasChild = $child ? true : false;
if ($post) {
    $postRow = Posts::where('alias', $post)->first();
}
?>
{{ $post&&isset($postRow) ? $postRow->title : ''}}
{{$page->title}}
{{$hasChild ? $child->title : ''}}
@endsection

@section('links')

@endsection

@section('content')

  <div class="lunbo-box cleard">
        <img src="/vendor/qz/images/top-3.jpg" height="400" width="100%" alt="" />
        
  </div><!-- top 輪播 -->
<!-- start content -->
開發者ID:koyeo,項目名稱:bichon,代碼行數:31,代碼來源:page.blade.php

示例3: die

        $data['id'] = $posts[$i]['id'];
        $data['title'] = $posts[$i]['title'];
        $data['slug'] = $posts[$i]['slug'];
        $data['content'] = $posts[$i]['content'];
        $data['created_at'] = $posts[$i]['created_at'];
        $author = Users::find($posts[$i]['author_id']);
        $data['author'] = $author->firstname;
        $results[] = $data;
    }
    die(json_encode($results));
});
//GET THE PARTICULAR POST
$app->get('/api/v1/posts/:slug', function ($slug) use($app) {
    $response = $app->response();
    $response->header('Access-Control-Allow-Origin', '*');
    $posts = Posts::where('slug', $slug)->get();
    $results = array();
    for ($i = 0; $i < sizeof($posts); $i++) {
        $data['id'] = $posts[$i]['id'];
        $data['title'] = $posts[$i]['title'];
        $data['slug'] = $posts[$i]['slug'];
        $data['content'] = $posts[$i]['content'];
        $data['created_at'] = $posts[$i]['created_at'];
        $author = Users::find($posts[$i]['author_id']);
        $data['author'] = $author->firstname;
    }
    $results[] = $data;
    die(json_encode($results));
});
$app->post('/api/v1/posts', function () use($app) {
    $posts = new Posts();
開發者ID:jsdecena,項目名稱:synthesis,代碼行數:31,代碼來源:posts.php

示例4: function

{
    protected $table = 'posts';
    protected $fillable = [];
}
//GET ALL THE USERS
$app->get('/api/v1/pages', function () use($app) {
    $response = $app->response();
    $response->header('Access-Control-Allow-Origin', '*');
    $pages = Posts::where('post_type', 2)->get();
    $response->write(json_encode($pages));
});
//GET THE PARTICULAR USER
$app->get('/api/v1/pages/:slug', function ($slug) use($app) {
    $response = $app->response();
    $response->header('Access-Control-Allow-Origin', '*');
    $pages = Posts::where('slug', $slug)->first();
    $response->write(json_encode($pages));
});
$app->post('/api/v1/pages', function () use($app) {
    $pages = new Posts();
    $pages->title = $app->request()->post('title');
    $pages->slug = str_replace(' ', '-', $app->request()->post('slug'));
    $pages->content = $app->request()->post('content');
    $pages->author_id = $app->request()->post('author_id');
    $pages->save();
    die(json_encode($pages));
});
$app->put('/api/v1/pages/:id', function ($id) use($app) {
    $pages = Posts::find($id);
    $pages->title = $app->request()->post('title');
    $pages->slug = str_replace(' ', '-', $app->request()->post('slug'));
開發者ID:jsdecena,項目名稱:slimapp,代碼行數:31,代碼來源:pages.php

示例5: managePosts

 public function managePosts()
 {
     $posts = Posts::where('user_id', '=', Auth::id())->get();
     return View::make('manage_posts', array('posts' => $posts));
 }
開發者ID:amadey18,項目名稱:laravel_first_test,代碼行數:5,代碼來源:PostsController.php

示例6: show

 /**
  * Display the specified topic.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $posts = Posts::where('topic_id', '=', $id)->get();
     return View::make('topics.show', compact('posts'));
 }
開發者ID:Abenaman,項目名稱:ggc-talk,代碼行數:11,代碼來源:Posts_TopicController.php

示例7: index

 public function index()
 {
     $posts = Posts::where('active', 1)->orderby('created_at', 'desc')->paginate(5);
     $title = 'Latest Posts';
     return view('home')->withPosts($posts)->withTitle($title);
 }
開發者ID:Vishalhari,項目名稱:myblog,代碼行數:6,代碼來源:UserController.php

示例8: array

            $app->redirect($settings->base_url . '/admin/users/new');
        }
        if ($email == "" or !filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $app->flash('error', 3);
            $app->redirect($settings->base_url . '/admin/users/new');
        }
        $redirect = $settings->base_url . '/admin/users';
        Users::insert(array('username' => $username, 'password' => $password, 'email' => $email, 'created_at' => $created_at));
        $app->render('success.html', array('redirect' => $redirect));
    });
    $app->get('/posts/activate/:id', $authenticate($app, $settings), function ($id) use($app, $settings) {
        $post = Posts::where('id', '=', $id)->first();
        if ($post) {
            $redirect = $settings->base_url . '/admin';
            $post->update(array('active' => 'true'));
            $app->render('success.html', array('redirect' => $redirect));
        } else {
            $app->render('404_post.html');
        }
    })->conditions(array('id' => '\\d+'));
    $app->get('/posts/deactivate/:id', $authenticate($app, $settings), function ($id) use($app, $settings) {
        $post = Posts::where('id', '=', $id)->first();
        if ($post) {
            $redirect = $settings->base_url . '/admin';
            $post->update(array('active' => 'false'));
            $app->render('success.html', array('redirect' => $redirect));
        } else {
            $app->render('404_post.html');
        }
    })->conditions(array('id' => '\\d+'));
});
開發者ID:kuslahne,項目名稱:SlimBlog,代碼行數:31,代碼來源:admin.route.php

示例9: template_form

 public function template_form()
 {
     $objPost = new Posts();
     $objTaxonomyitem = new Taxonomyitem();
     $objTaxonomyitem = $objTaxonomyitem->where('vid', '=', '5')->get();
     $i = 0;
     $mang = array();
     foreach ($objTaxonomyitem as $row) {
         $mang[$i] = $row;
         $mang[$i++]['sub'] = $objPost->where('cat_id', '=', $row['id'])->where('status', '=', 1)->get();
     }
     return view('frontend::template_forms', array('mang' => $mang));
 }
開發者ID:manhvu1212,項目名稱:videoplatform,代碼行數:13,代碼來源:FrontendController.php


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