Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function deleteAsset()
 {
     $id = Input::get('id');
     $asset = asset::find($id);
     $asset->status = 'deleted';
     if ($asset->save()) {
         return 'success';
     } else {
         return 'faile';
     }
 }
Exemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function editdevice($id)
 {
     $device = devices::find($id);
     $device->name = Input::get('name');
     $device->system = Input::get('system');
     $device->mac = Input::get('mac');
     $device->ip = Input::get('ip');
     $device->type = Input::get('type');
     $device->people_id = Input::get('owner');
     $device->remark = Input::get('remark');
     $device->save();
     $assetAaary = ['cpu', 'memory', 'mainboard', 'harddisk'];
     foreach ($assetAaary as $a) {
         if (!Input::get($a) == "") {
             $allAsset = explode(';', Input::get($a));
             foreach ($allAsset as $key) {
                 if (strpos($key, '##')) {
                     $id = explode('##', $key)[0];
                     $asset = asset::find($id);
                     if ($asset->status == 'using') {
                         $message = ['message' => $key . 'already using'];
                         return Redirect::back()->withInput()->withErrors($message);
                     }
                     $asset->status = 'using';
                     $asset->device_id = $device->id;
                     $asset->save();
                 } else {
                     $asset = new asset();
                     $asset->type = $a;
                     $asset->name = $key;
                     $asset->status = 'using';
                     $asset->device_id = $device->id;
                     $asset->created_at = date('Y-m-d');
                     $asset->save();
                 }
             }
         }
     }
     return Redirect::back();
 }