本文整理汇总了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);
}