예제 #1
0
 public function findOrThrowException($id)
 {
     $article = Article::find($id);
     if (!is_null($article)) {
         return $article;
     }
     throw new GeneralException(trans('exceptions.backend.article.not_found'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // Start transaction!
     \DB::beginTransaction();
     try {
         $Article = Article::find($id);
         if ($Article) {
             $this->withdraw($Article);
             //Article_I10n
             $ArticleI10ns = Article_I10N::where('i18n_id', '=', $id)->get();
             if ($ArticleI10ns) {
                 foreach ($ArticleI10ns as $ArticleI10n) {
                     $this->withdraw($ArticleI10n);
                 }
             }
             // Commit
             \DB::commit();
             return Response::json(['result' => 'OK']);
         }
     } catch (\ValidationException $e) {
         // Rollback and then redirect
         DB::rollback();
         App::abort(404);
     }
     // Rollback
     DB::rollback();
 }