当前位置: 首页>>代码示例>>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;未经允许,请勿转载。