Beispiel #1
0
 /**
  * Map routes.
  *
  * @param  \Illuminate\Contracts\Routing\Registrar  $router
  */
 public function map(Registrar $router)
 {
     $this->group(['prefix' => 'posts', 'as' => 'posts.'], function () {
         $this->get('/', ['as' => 'index', 'uses' => 'PostsController@index']);
         $this->get('trashed', ['as' => 'trash', 'uses' => 'PostsController@trash']);
         $this->get('create', ['as' => 'create', 'uses' => 'PostsController@create']);
         $this->post('store', ['as' => 'store', 'uses' => 'PostsController@store']);
         $this->group(['prefix' => '{blog_post_id}'], function () {
             $this->get('show', ['as' => 'show', 'uses' => 'PostsController@show']);
             $this->get('edit', ['as' => 'edit', 'uses' => 'PostsController@edit']);
             $this->put('update', ['as' => 'update', 'uses' => 'PostsController@update']);
             $this->put('publish', ['as' => 'publish', 'uses' => 'PostsController@publish']);
             $this->put('restore', ['as' => 'restore', 'uses' => 'PostsController@restore']);
             $this->delete('delete', ['as' => 'delete', 'uses' => 'PostsController@delete']);
         });
     });
     $this->bind('blog_post_id', function ($postId) {
         return Post::withTrashed()->findOrFail($postId);
     });
 }
Beispiel #2
0
 public function update(UpdatePostRequest $request, Post $post)
 {
     $this->authorize('blog.posts.update');
     $post->updateOne($request->all());
     $message = "The post {$post->title} was updated successfully !";
     Log::info($message, $post->toArray());
     $this->notifySuccess($message, 'Post updated !');
     return redirect()->route('blog::foundation.posts.show', [$post->id]);
 }