Exemplo n.º 1
0
 /**
  * @param $id
  * @return \Illuminate\Contracts\View\View
  */
 public function edit($id)
 {
     $article = Article::findOrFail($id);
     $category = Category::findOrFail($article->category_id);
     $this->share('article', $article);
     $this->share('category', $category);
     return $this->view($category->getArticleTemplate('edit'));
 }
Exemplo n.º 2
0
 /**
  * Category constructor.
  * @param $id
  */
 public function __construct($id)
 {
     $this->id = $id;
     $this->model = CategoryModel::findOrFail($id);
 }
 /**
  * @param \Notadd\Category\Requests\CategoryEditRequest $request
  * @param $id
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function update(CategoryEditRequest $request, $id)
 {
     $category = Category::findOrFail($id);
     if ($category->update($request->all())) {
         return $this->redirect->back();
     } else {
         return $this->redirect->back()->withInput()->withErrors('保存失败!');
     }
 }