コード例 #1
0
 public function show($name)
 {
     if (\Auth::check() && \Auth::user()->permission->name == 'admin') {
         if (is_numeric($name)) {
             $dl = Downloads::where('id', '=', $name)->where('trash', '=', '0')->first();
             if (is_null($dl)) {
                 return \Redirect::to('404');
             }
             return \View::make('downloads.show')->with('entry', $dl);
         } else {
             $dl = Downloads::where('name', '=', $name)->where('trash', '=', '0')->first();
             if (is_null($dl)) {
                 return \Redirect::to('404');
             }
             return \View::make('downloads.show')->with('entry', $dl);
         }
     } else {
         if (is_numeric($name)) {
             $dl = Downloads::where('id', '=', $name)->where('trash', '=', '0')->where('state', '=', '1')->first();
             if (is_null($dl)) {
                 return \Redirect::to('404');
             }
             return \View::make('downloads.show')->with('entry', $dl);
         } else {
             $dl = Downloads::where('name', '=', $name)->where('trash', '=', '0')->where('state', '=', '1')->first();
             if (is_null($dl)) {
                 return \Redirect::to('404');
             }
             return \View::make('downloads.show')->with('entry', $dl);
         }
     }
 }
コード例 #2
0
 public function delete($id)
 {
     $entry = Downloads::find($id);
     if (isset($entry)) {
         Downloads::where('id', $id)->update(array('trash' => 1));
         return \Redirect::route('downloads', array($id))->with('success', $entry->title . ' deleted succesfully!');
     } else {
         return \Redirect::route('downloads', array($id))->with('error', 'Failed to delete, invalid credentials.');
     }
 }