Пример #1
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $post = Post::where('slug', $this->old_slug)->first();
     $post->category_id = $this->category_id;
     $post->name = $this->name;
     $post->slug = $this->slug;
     $post->content = $this->content;
     $post->save();
 }
Пример #2
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('category', function ($slug) {
         return Category::where('slug', $slug)->first();
     });
     $router->bind('post', function ($slug) {
         return Post::where('slug', $slug)->first();
     });
     $router->bind('page', function ($slug) {
         return Page::where('slug', $slug)->first();
     });
 }
Пример #3
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     Post::where('slug', $this->slug)->first()->delete();
 }
Пример #4
0
 /**
  * Display the specified resource.
  *
  * @param  int $year
  * @param  int $month
  * @return Response
  */
 public function show($year, $month = null)
 {
     return view('index', ['posts' => Post::archiveFiltered($year, $month)->with('category')->paginate(3)]);
 }
Пример #5
0
 /**
  * Display the specified resource.
  *
  * @param  string  $slug
  * @return Response
  */
 public function show($category)
 {
     return view('index', ['posts' => Post::where('category_id', $category->id)->with('category')->orderBy('created_at', 'DESC')->paginate(5)]);
 }
Пример #6
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $archives = Post::archiveLatest('F Y');
     $view->with('archives', $archives);
 }
 /**
  * Get Post by ID
  *
  * @param $post_id
  * @return Post
  */
 public function find($post_id)
 {
     return $this->post->findOrFail($post_id);
 }
Пример #8
0
 /**
  * Display the specified resource.
  *
  * @param  Post $post
  * @return Response
  */
 public function show(Post $post)
 {
     return view('post.show', ['post' => $post, 'comments' => $post->comments()->whereNull('parent_id')->with('childrenRecursive')->orderBy('created_at', 'desc')->get()]);
 }
Пример #9
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     Post::create(['category_id' => $this->category_id, 'name' => $this->name, 'slug' => $this->slug, 'content' => $this->content]);
 }