Example #1
0
 public function getAll($order_by = 'id', $sort = 'asc')
 {
     return Article::orderByDate()->paginate(15);
 }
 /**
  * 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();
 }