示例#1
0
 /**
  * Save bulk deleted.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @param  array  $assets
  * @since [v2.0]
  * @return View
  */
 public function postBulkDelete($assets = null)
 {
     if (!Company::isCurrentUserAuthorized()) {
         return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
     } elseif (Input::has('bulk_edit')) {
         //$assets = Input::get('bulk_edit');
         $assets = Asset::find(Input::get('bulk_edit'));
         //print_r($assets);
         foreach ($assets as $asset) {
             //echo '<li>'.$asset;
             $update_array['deleted_at'] = date('Y-m-d h:i:s');
             $update_array['assigned_to'] = null;
             if (DB::table('assets')->where('id', $asset->id)->update($update_array)) {
                 $logaction = new Actionlog();
                 $logaction->asset_id = $asset->id;
                 $logaction->asset_type = 'hardware';
                 $logaction->created_at = date("Y-m-d H:i:s");
                 $logaction->user_id = Auth::user()->id;
                 $log = $logaction->logaction('deleted');
             }
         }
         // endforeach
         return redirect()->to("hardware")->with('success', trans('admin/hardware/message.delete.success'));
         // no values given, nothing to update
     } else {
         return redirect()->to("hardware")->with('info', trans('admin/hardware/message.delete.nothing_updated'));
     }
     // Something weird happened here - default to hardware
     return redirect()->to("hardware");
 }