/** * Execute the job. * * @return bool */ public function handle() { $this->system->name = $this->request->input('name'); $this->system->version = $this->request->input('version'); $this->system->service_pack = $this->request->input('service_pack'); return $this->system->save(); }
/** * Deletes the specified operating system. * * @param int|string $id * * @return \Illuminate\Http\RedirectResponse */ public function destroy($id) { $system = $this->system->findOrFail($id); if ($system->delete()) { flash()->success('Success!', 'Successfully deleted operating system.'); return redirect()->route('computer-systems.index'); } flash()->error('Error!', 'There was an issue deleting this operating system. Please try again.'); return redirect()->route('computer-systems.index'); }
/** * Creates an operating system. * * @return OperatingSystem|false */ public function handle() { if (!is_null($this->name)) { $os = OperatingSystem::firstOrNew(['name' => $this->name]); $os->version = $this->version; $os->service_pack = $this->servicePack; if ($os->save()) { return $os; } } return false; }
/** * Execute the job. * * @return Computer|bool */ public function handle() { $this->computer->os_id = OperatingSystem::findOrFail($this->request->input('os'))->id; $this->computer->type_id = ComputerType::findOrFail($this->request->input('type'))->id; $this->computer->name = $this->request->input('name'); $this->computer->ip = $this->request->input('ip'); $this->computer->model = $this->request->input('model'); $this->computer->description = $this->request->input('description'); if ($this->computer->save()) { return $this->computer; } return false; }
/** * Returns a new form for computers. * * @param Computer $computer * * @return \Orchestra\Contracts\Html\Builder */ public function form(Computer $computer) { return $this->form->of('computers', function (FormGrid $form) use($computer) { $operatingSystems = OperatingSystem::all()->pluck('name', 'id'); $types = ComputerType::all()->pluck('name', 'id'); if ($computer->exists) { $method = 'PATCH'; $url = route('computers.update', [$computer->id]); $form->submit = 'Save'; } else { $method = 'POST'; $url = route('computers.store'); $form->submit = 'Create'; } $form->with($computer); $form->attributes(compact('method', 'url')); $form->fieldset(function (Fieldset $fieldset) use($computer, $operatingSystems, $types) { $fieldset->control('input:text', 'name')->label('Name')->attributes(['placeholder' => 'Name']); $fieldset->control('input:text', 'ip')->label('IP Address')->attributes(['placeholder' => '10.0.0.XXX']); $fieldset->control('select', 'os')->label('Operating System')->options($operatingSystems)->value(function (Computer $computer) { if ($computer->os instanceof OperatingSystem) { return $computer->os->id; } })->attributes(['class' => 'form-control', 'placeholder' => 'Select An Operating System']); $fieldset->control('select', 'type')->label('Type')->options($types)->value(function (Computer $computer) { if ($computer->type instanceof ComputerType) { return $computer->type->id; } })->attributes(['class' => 'form-control', 'placeholder' => 'Select a Type']); $fieldset->control('input:text', 'model')->label('Model')->attributes(['placeholder' => 'Model']); $fieldset->control('input:textarea', 'description')->label('Description')->attributes(['placeholder' => 'Description']); if (!$computer->exists) { // We'll only allow the exists in active directory checkbox if // the computer hasn't been created yet. This is due to // the access panel and can be updated there. $fieldset->control('input:checkbox', 'Exists in Active Directory?')->attributes(['class' => 'switch-mark'])->name('active_directory')->value(1); } }); }); }