Exemplo n.º 1
0
 /**
  * Article constructor.
  * @param $id
  */
 public function __construct($id)
 {
     $this->id = $id;
     $this->model = ArticleModel::findOrFail($id);
 }
Exemplo n.º 2
0
 /**
  * @param \Notadd\Article\Requests\ArticleEditRequest $request
  * @param $id
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function update(ArticleEditRequest $request, $id)
 {
     $article = Article::findOrFail($id);
     $request->offsetSet('user_id', $this->app->make('auth')->user()->id);
     $request->offsetSet('created_at', new Carbon($request->offsetGet('created_at')));
     if ($article->update($request->all())) {
         return $this->redirect->to('admin/article');
     } else {
         return $this->redirect->back()->withInput()->withErrors('保存失败!');
     }
 }