/** * Handle the creation of the Field in the Database * @param $command * @return static */ public function handle($command) { $command->namespace = EntityModel::find($command->entity_id)->namespace; $field = FieldModel::create((array) $command); event(new FieldWasCreated($field)); return $field; }
public function handle($command) { $model = FieldModel::find($command->id); $modelArray = $model->toArray(); $model->delete(); event(new FieldWasDeleted($modelArray)); }
/** * @param object $command * @param callable $next * * @return mixed */ public function execute($command, callable $next) { $model = FieldModel::find($command->id); if (!isset($command->locked)) { $command->locked = $model->locked; } return $next($command); }
/** * Edit a field for the Board * @param int $id ID of the field * @return $this */ public function edit($id) { $field = FieldModel::findOrFail($id); $entity = $field->entity; $builder = new FormBuilder($entity); $builder->setReturnUrl(route('tasks.config.index')); $builder->setModel($field); JavaScript::put(['entity_id' => $entity->id, 'field_id' => $field->id]); return view('tasks::config.tasks.edit')->with('form', $builder->render()); }
/** * @param $command * @return mixed */ public function handle($command) { $order = 1; foreach ($command->fields as $field) { $f = FieldModel::find($field); $f->order = $order; $f->save(); $order++; } return $field; }
/** * Handle the creation of the Field in the Database * @param $command * @return static */ public function handle($command) { $fields = (array) $command; $model = FieldModel::find($command->id); $rename = false; $oldSlug = $model->slug; if ($model->slug !== $command->slug) { $rename = true; } unset($fields['id']); $model->fill($fields); $model->save(); event(new FieldWasEdited($model, $rename, $oldSlug)); return $model; }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { return $this->responseWithItem($this->model->findOrFail($id), new FieldTransformer()); }
/** * @param object $command * @param callable $next * * @return mixed */ public function execute($command, callable $next) { $field = FieldModel::find($command->id); $command->type = $field->type; return $next($command); }