本文整理汇总了PHP中app\Post::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::with方法的具体用法?PHP Post::with怎么用?PHP Post::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//User::create(['email' => 'test@test.fr', 'password' => Hash::make('test')]);
//Auth::logout();
$posts = Post::with('category')->Published()->get();
return view('posts.index', compact('posts'));
}
示例2: getFeed
public function getFeed($type = null)
{
$feed = App::make('feed');
//$feed->setCache(60);
$parsedown = new Parsedown();
$parsedown->setMarkupEscaped(true);
if (!is_null($type)) {
$posts = Post::where('feed', $type)->with('user')->orderBy('created_at', 'desc')->take(20)->get();
} else {
$posts = Post::with('user')->orderBy('created_at', 'desc')->take(20)->get();
}
$pubDate = count($posts) == 0 ? date('Y-m-d H:i:s') : $posts[0]->created_at;
$feed->title = 'rhofma.de - Blog';
$feed->description = 'Web-Developer Blog';
$feed->logo = asset('img/logo.svg');
$feed->link = URL::to('/');
$feed->setDateFormat('datetime');
$feed->pubdate = $pubDate;
$feed->lang = 'de';
$feed->setShortening(true);
$feed->setTextLimit(500);
foreach ($posts as $post) {
$feed->add($post->title, $post->user->name, URL::to($post->slug), $post->created_at, $text = $post->teaser, $parsedown->parse($post->content));
}
return $feed;
}
示例3: getIndex
public function getIndex()
{
$posts = Cache::remember('site.overboard', 60, function () {
return Post::with('op', 'board', 'board.assets')->withEverything()->orderBy('post_id', 'desc')->take(75)->paginate(15);
});
return $this->view(static::VIEW_MULTIBOARD, ['posts' => $posts]);
}
示例4: getData
public function getData($id, $title, $kode)
{
$dateNow = Carbon::now();
$kelasDosen = Perkuliahan::select('kodekelas')->where('nip', '=', $id)->get()->toArray();
$data = array('dosen' => DB::table('dosen')->where('nip', $id)->first(), 'dosenProfile' => Dosen::where('nip', '=', Request::segment(3))->first(), 'kelas' => Mhskelas::with(array('mhs', 'perkuliahan', 'mk'))->where('nim', '=', $id)->get(), 'kelasDosen' => Perkuliahan::with(array('mk', 'dosen'))->where('nip', '=', $id)->get(), 'title' => $title, 'listPerkuliahan' => ['' => '-- Pilih kelas --'] + Mhskelas::select('matakuliah.namamk', 'mhskelas.kodekelas')->join('matakuliah', 'mhskelas.kodemk', '=', 'matakuliah.kodemk')->join('mahasiswa', 'mhskelas.nim', '=', 'mahasiswa.nim')->where('mahasiswa.nim', '=', $id)->lists('matakuliah.namamk', 'mhskelas.kodekelas'), 'perkuliahanDosen' => ['' => '-- Pilih kelas --'] + Perkuliahan::select('perkuliahan.kodekelas', 'matakuliah.namamk')->join('matakuliah', 'matakuliah.kodemk', '=', 'perkuliahan.kodemk')->where('perkuliahan.nip', '=', $id)->lists('matakuliah.namamk', 'perkuliahan.kodekelas'), 'grup' => AnggotaGrup::select('grup.nama', 'grup.kodekelas')->join('grup', 'grup.id', '=', 'anggota_grup.id_grup')->where('anggota_grup.nim', '=', $id)->get(), 'post' => Post::with(array('komentar', 'mhs', 'perkuliahan'))->where('creator', '=', $id)->get(), 'postKelas' => Post::with(array('komentar', 'mhs', 'perkuliahan'))->where('id_scope', '=', $kode)->get(), 'kelasMember' => Mhskelas::with('mhs')->where('kodekelas', '=', $kode)->get(), 'infokelas' => Perkuliahan::with('mk', 'dosen')->where('kodekelas', '=', $kode)->first(), 'tugasDosen' => Tugas::where('pengumpulan', '>=', $dateNow)->whereIn('kelas', $kelasDosen)->get(), 'pengumumanDosen' => Pengumuman::where('waktuaktif', '>=', $dateNow)->whereIn('kodekelas', $kelasDosen)->get());
return $data;
}
示例5: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$user = Sentinel::findById($id);
$activation = Activation::exists($user);
$posts = Post::with(['thread', 'thread.category'])->where('user_id', $user->id)->orderBy('created_at', 'desc')->get();
return view('admin.users.show', compact('user', 'activation', 'posts'));
}
示例6: index
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index()
{
$posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->orderBy('created_at', 'desc')->take(4)->get();
$mostPopular = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->take(4)->get();
$communities = Community::all();
$cities = City::all();
return view('pages.home', ['posts' => $posts, 'mostPopular' => $mostPopular, 'communities' => $communities, 'cities' => $cities]);
}
示例7: looks
/**
* Display all looks by User
*
* @return Response
*/
public function looks($userId)
{
if (!User::find($userId)) {
throw new NotFoundHttpException('no user found');
}
$looks = Post::with(['location', 'brands', 'look', 'post_author', 'comments', 'comments.comment_author'])->where('user_id', $userId)->where('is_look', true)->get();
return response()->json($looks);
}
示例8: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$post = Post::with(['location', 'photos', 'brands', 'look', 'post_author', 'comments', 'comments.comment_author'])->where('id', $id)->get();
if (!$post || !count($post)) {
throw new NotFoundHttpException('no post found');
}
return response()->json($post);
}
示例9: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($slug)
{
$tag = Tag::where('slug', $slug)->firstOrFail();
$posts = Post::with('tags')->whereHas('tags', function ($q) use($tag) {
$q->where('tag_id', $tag->id);
})->orderBy('created_at', 'desc')->paginate(15);
return view('tags.show', compact('tag', 'posts'));
}
示例10: index
public function index()
{
$totallikes = Like::count();
$totalposts = Post::count();
$posts = Post::with('cat', 'likes')->paginate(config('app.posts_per_page'));
$page = $posts->currentPage();
$lastpage = $posts->lastPage();
return view('index', compact('totallikes', 'totalposts', 'posts', 'page', 'lastpage', 'title'));
}
示例11: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(Request $request)
{
$req = Post::with('user')->with('category')->with('job')->orderBy('updated_at', 'desc');
if ($request->has('filterBy')) {
$req->where($request->get('filterBy') . '_id', $request->get('id'));
}
$posts = $req->get();
return view('admin.posts.index', compact('posts'));
}
示例12: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(Subreddit $subreddit, Post $post, Moderator $moderator, User $user)
{
//$posts = Post::with('user.votes')->get();
$posts = Post::with('user.votes')->with('subreddit.moderators')->orderBy('created_at', 'desc')->get();
//$ids = $posts->subreddit;
$isModerator = false;
//dd($ids);
return view('home')->with('posts', $posts)->with('isModerator', $isModerator);
}
示例13: showPost
public function showPost($slug, Request $request)
{
$post = Post::with('tags')->whereSlug($slug)->firstOrFail();
$tag = $request->get('tag');
if ($tag) {
$tag = Tag::whereTag($tag)->firstOrFail();
}
return view($post->layout, compact('post', 'tag'));
}
示例14: index
/**
* Display a listing of the resource.
*
* @param Request $request
* @return Response
*/
public function index(Request $request)
{
if ($id = $request->get('tag')) {
$tag = Tag::findOrFail($id);
return $tag->posts()->with('tags')->get();
} else {
return Post::with('tags')->latest()->take(5)->get();
}
}
示例15: getDetail
/**
* Display single post
*/
public function getDetail($id, $page)
{
$post = Post::with('get_category')->find($id);
if ($page == 'unpublished') {
return view('admin/post/detailPost', array('user' => $this->username, 'nav_post' => '', 'nav_list_post' => '', 'post' => $post, 'page' => $page));
} elseif ($page == 'published') {
return view('admin/post/detailPost', array('user' => $this->username, 'nav_post' => '', 'nav_pub_post' => '', 'post' => $post, 'page' => $page));
}
}