コード例 #1
0
ファイル: CreatePostRequest.php プロジェクト: arcanesoft/blog
 /**
  * Update request rules.
  *
  * @param  array  $rules
  *
  * @return array
  */
 private function updateRules(array $rules)
 {
     $rules['category'] .= '|in:' . implode(',', array_keys(Category::getSelectOptions(false)));
     $rules['tags'] .= '|in:' . implode(',', array_keys(Tag::getSelectOptions()));
     $rules['status'] .= '|in:' . implode(',', PostStatus::keys());
     return $rules;
 }
コード例 #2
0
ファイル: TagsRoutes.php プロジェクト: arcanesoft/blog
 /**
  * Map routes.
  *
  * @param  \Illuminate\Contracts\Routing\Registrar  $router
  */
 public function map(Registrar $router)
 {
     $this->group(['prefix' => 'tags', 'as' => 'tags.'], function () {
         $this->get('/', ['as' => 'index', 'uses' => 'TagsController@index']);
         $this->get('trash', ['as' => 'trash', 'uses' => 'TagsController@trash']);
         $this->get('create', ['as' => 'create', 'uses' => 'TagsController@create']);
         $this->post('store', ['as' => 'store', 'uses' => 'TagsController@store']);
         $this->group(['prefix' => '{blog_tag_id}'], function () {
             $this->get('/', ['as' => 'show', 'uses' => 'TagsController@show']);
             $this->get('edit', ['as' => 'edit', 'uses' => 'TagsController@edit']);
             $this->put('update', ['as' => 'update', 'uses' => 'TagsController@update']);
             $this->put('restore', ['as' => 'restore', 'uses' => 'TagsController@restore']);
             $this->delete('delete', ['as' => 'delete', 'uses' => 'TagsController@delete']);
         });
     });
     $this->bind('blog_tag_id', function ($id) {
         return Tag::withTrashed()->findOrFail($id);
     });
 }
コード例 #3
0
ファイル: TagsController.php プロジェクト: arcanesoft/blog
 public function delete(Tag $tag)
 {
     self::onlyAjax();
     $this->authorize('blog.tags.delete');
     try {
         if ($tag->trashed()) {
             $tag->forceDelete();
         } else {
             $tag->delete();
         }
         $message = "The tag {$tag->name} has been successfully deleted !";
         Log::info($message, $tag->toArray());
         $this->notifySuccess($message, 'Tag deleted !');
         $ajax = ['status' => 'success', 'message' => $message];
     } catch (\Exception $e) {
         $ajax = ['status' => 'error', 'message' => $e->getMessage()];
     }
     return response()->json($ajax);
 }
コード例 #4
0
ファイル: PostsController.php プロジェクト: arcanesoft/blog
 /**
  * Edit a post.
  *
  * @param  \Arcanesoft\Blog\Models\Post  $post
  *
  * @return \Illuminate\View\View
  */
 public function edit(Post $post)
 {
     $this->authorize('blog.posts.update');
     $title = 'Blog - Posts';
     $this->setTitle($title);
     $this->addBreadcrumb('Edit post');
     $categories = Category::getSelectOptions();
     $tags = Tag::getSelectOptions();
     $statuses = PostStatus::all();
     return $this->view('foundation.posts.edit', compact('post', 'categories', 'tags', 'statuses'));
 }