示例#1
0
 /**
  * Response with error message.
  * @param $message
  * @return $this|static
  */
 protected function error($message)
 {
     if (Request::ajax()) {
         return CMSResponse::failed([$message]);
     }
     return view('cms::app', compact('user'))->withErrors([$message]);
 }
示例#2
0
 /**
  * Update the specified resource in storage.
  * @usage /models/edit/1
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function update(Model $model, Request $request)
 {
     $class = $this->setClass($model->getClass());
     $input = $request->all();
     $validator = $model->validate($input);
     if ($validator->fails()) {
         return CMSResponse::failed($validator->errors()->all());
     }
     if ($model->update($input)) {
         return CMSResponse::updated($model);
     }
     // Something else went wrong...
     return CMSResponse::failed($model);
 }