本文整理匯總了PHP中HomeController::previewFirstSimbol方法的典型用法代碼示例。如果您正苦於以下問題:PHP HomeController::previewFirstSimbol方法的具體用法?PHP HomeController::previewFirstSimbol怎麽用?PHP HomeController::previewFirstSimbol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HomeController
的用法示例。
在下文中一共展示了HomeController::previewFirstSimbol方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getPage
public function getPage($type, $slug = '')
{
$type_post = Type::where('type', $type)->first();
$posts_child = $galleries = $posts = $row = array();
if (empty($type_post)) {
return Response::view('errors.not-found')->header('Content-Type', '404 Not Found');
}
if ($type_post->template == 'gallery') {
$row = Post::where('slug', $type)->first();
$type_post = Type::where('id', $row->type_id)->first();
$galleries = Gallery::where('post_id', $row->id)->get();
} else {
if ($type_post->template == 'news') {
if ($slug == '') {
$posts = Post::where('type_id', $type_post->id)->where('status', 1)->where('parent', 0)->orderBy('created_at', 'desc')->paginate(6);
} else {
$row = Post::where('slug', $slug)->first();
}
foreach ($posts as $key => $post) {
$preview = HomeController::previewFirstSimbol($post->text, 500);
$post->preview = $preview['text'];
}
} else {
if ($type_post->template == 'portfolio') {
$posts = Post::where('type_id', $type_post->id)->where('status', 1)->where('parent', 0)->orderBy('order', 'asc')->get();
foreach ($posts as $key => $post) {
$post->galleries = Gallery::where('post_id', $post->id)->get();
}
} else {
$posts = Post::where('type_id', $type_post->id)->where('status', 1)->where('parent', 0)->orderBy('order', 'asc')->get();
$posts_child = Post::where('type_id', $type_post->id)->where('status', 1)->where('parent', '!=', 0)->orderBy('order', 'asc')->get();
if ($slug != '') {
$row = Post::where('slug', $slug)->first();
if ($row->parent != 0) {
$parent = Post::where('id', $row->parent)->first();
$row->parent_title = $parent->name;
$row->parent_slug = $parent->slug;
}
$galleries = Gallery::where('post_id', $row->id)->get();
}
}
}
}
$view = array('type' => $type_post, 'posts' => $posts, 'posts_child' => $posts_child, 'row' => $row, 'galleries' => $galleries);
return View::make('home.' . $type_post->template, $view);
}