I have a category page and in this I want to display two types of box in single page, one is starting_post and old_post or expired, how can divide a single page in two part?
class FrontendController extends Controller { public function welcome()
{
// @TODO Refactor This Line
return view('welcome')
->with('title', Setting::first()->site_name)
->with('levels', Category::take(7)->get())
->with('levels', Category::take(7)->get())
->with('first_post', Post::orderBy('created_at','asc')->first())
->with('second_post', Post::orderBy('created_at', 'asc')->skip(1)->take(1)->get()->first())
->with('third_post', Post::orderBy('created_at','asc')->skip(2)->take(2)->get()->first())
->with('forth_post', Post::orderBy('created_at','asc')->skip(3)->take(3)->get()->first())
->with('HOME', Category::find(1))
->with('ABOUT US', Category::find(2))
->with('RESEARCH', Category::find(3))
->with('NEWS AND PUBLICATION', Category::find(4))
->with('EVENTS', Category::find(5))
->with('PEOPLE', Category::find(6))
->with('CONTACT US',Category::find(7));
}
public function singlePost($slug)
{
$post=Post::whereSlug($slug)->first();
return view('single')->with('post', $post)
->with('content', $post)
->with('levels', Category::take(7)->get());
}
public function category($slug)
{ $category=Category::whereSlug($slug)->firstOrFail();
return view($category->getTemplateFile())->with('category', $category)
->with('title',$category->name)
->with('levels', Category::take(7)->get());
}
public function events($slug) { $post = Post::where('slug', $slug)->first();
$coming_events = Post::where('id', '>', $post->id)->desc('id');
$past_events = Post::where('id', '<', $post->id)->asc('id');
return view('events_blade')
->with('post', $post)
->with('categories', Category::take(7)->get())
->with('next', Post::find($coming_events))
->with('prev', Post::find($past_events));
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire