本文整理汇总了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);
}
示例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 -->
示例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();
示例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'));
示例5: managePosts
public function managePosts()
{
$posts = Posts::where('user_id', '=', Auth::id())->get();
return View::make('manage_posts', array('posts' => $posts));
}
示例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'));
}
示例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);
}
示例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+'));
});
示例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));
}