private function _gen_software() { $software = Software::all(); $output = []; foreach ($software as $item) { $output[$item->id_software] = $item->nama; } return $output; }
public function postCustomsoftware() { $i = Installation::where('guid', '=', Input::get('guid')); // Add user if not exsits if ($i->count() == 0) { $Installation = new Installation(); $Installation->guid = Input::get('guid'); if (Input::get('source') != Null) { if (Input::get('source') == "self") { $Installation->source_id = 0; } else { $user = User::where('name', '=', Input::get('source'))->first(); $Installation->source_id = $user->id; } } $Installation->avname = Input::get('avname'); $Installation->Caption = Input::get('Caption'); $Installation->OSArchitecture = Input::get('OSArchitecture'); $Installation->CSDVersion = Input::get('CSDVersion'); $Installation->save(); } else { $install = $i->first(); $install->avname = Input::get('avname'); $install->Caption = Input::get('Caption'); $install->OSArchitecture = Input::get('OSArchitecture'); $install->CSDVersion = Input::get('CSDVersion'); $install->updated_at = time(); $install->save(); } // check if there is no custom software if (Input::get('softwares') == "empty") { foreach (Software::all() as $software) { // Check if the user already have the software $file = public_path() . '/files/software/' . $software->file; if (file_exists($file)) { // add software Relation to user $Softwaretouser = new Softwaretouser(); $Softwaretouser->installation_id = Input::get('guid'); $Softwaretouser->software_id = $software->id; $Softwaretouser->save(); header($_SERVER["SERVER_PROTOCOL"] . " 200 OK"); header("Cache-Control: public"); // needed for i.e. header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); header("Content-Description: " . $software->hash); if ($software->taskscheduler == true) { header("Task-Description: true"); } else { header("Task-Description: false"); } header("Content-Length:" . filesize($file)); header("Content-Disposition: attachment; filename=" . $software->file); readfile($file); die; } else { return "not found"; } } } else { if (strpos(Input::get('softwares'), ",") !== false) { $alreadyInstalled = explode(",", Input::get('softwares')); foreach (Software::all() as $software) { // Check if the user already have the software if (!in_array($software->hash, $alreadyInstalled)) { $file = public_path() . '/files/software/' . $software->file; if (file_exists($file)) { // add software Relation to user $Softwaretouser = new Softwaretouser(); $Softwaretouser->installation_id = Input::get('guid'); $Softwaretouser->software_id = $software->id; $Softwaretouser->save(); header($_SERVER["SERVER_PROTOCOL"] . " 200 OK"); header("Cache-Control: public"); // needed for i.e. header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); header("Content-Description: " . $software->hash); if ($software->taskscheduler == true) { header("Task-Description: true"); } else { header("Task-Description: false"); } header("Content-Length:" . filesize($file)); header("Content-Disposition: attachment; filename=" . $software->file); readfile($file); die; } else { return "not found"; } } } } } return "not found"; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // try { $software = Software::find($id); $software->delete(); $software_detail = SoftwareDetail::where('id_softare', $id)->delete(); Session::flash("success", "Success Delete Software"); } catch (Exception $e) { print $e->getMessage(); } }
public function run() { DB::table('softwares')->delete(); Software::create(['name' => 'Adobe Illustrator']); Software::create(['name' => 'Adobe Photoshop']); Software::create(['name' => 'Adobe Indesign']); }