Пример #1
0
 public function remove_article($id)
 {
     if (Auth::User()->admin) {
         article::destroy($id);
     } else {
         $article = Auth::User()->articles->find($id);
         if (!is_null($article)) {
             $article->delete();
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         article::destroy($id);
     } catch (QueryException $e) {
         return Redirect::back()->with('error', 'Gagal dihapus');
     } finally {
         return Redirect::to('/article')->with('message', 'Data berhasil dihapus');
     }
 }