/** * display * * @param \Illuminate\Database\Eloquent\Model $model * * @return mixed * * @throws \Just\Shapeshifter\Exceptions\MethodNotExistException */ public function compile(Model $model = null) { $this->checkDestinationModel($model); $descriptor = $this->destination->getDescriptor(); $table = $this->destination->getRepo()->getModel()->getTable(); $results = $model->{$this->function}()->get([$table . '.id', "{$descriptor} as name"])->lists('id'); $all = $this->destination->getRepo()->getModel()->get([$table . '.id', "{$descriptor} as name"])->lists('name', 'id'); return View::make('shapeshifter::relations.ManyToManyCheckboxRelation', ['results' => $results, 'all' => $all, 'name' => $this->name, 'label' => translateAttribute($this->name)])->render(); }
/** * display * * @param \Illuminate\Database\Eloquent\Model $model * * @return mixed * * @throws \Just\Shapeshifter\Exceptions\MethodNotExistException */ public function compile(Model $model = null) { $this->checkDestinationModel($model); $descriptor = $this->destination->getDescriptor(); $table = $this->destination->getRepo()->getModel()->getTable(); $results = $model->{$this->function}()->select($table . '.id')->lists('id')->filter(function ($item) { return (string) $item; })->toJson(); $all = $this->destination->getRepo()->getModel()->select($table . '.id', "{$descriptor} as name")->get()->toJson(); return View::make('shapeshifter::relations.ManyToManyFacebookRelation', ['results' => $results, 'all' => $all, 'name' => $this->name, 'label' => translateAttribute($this->name)])->render(); }
/** * getDisplayValue * * @param Model $model * * @return mixed Value. */ public function getDisplayValue(Model $model) { return $model->{$this->name} ? translateAttribute('yes') : translateAttribute('no'); }
/** * @return mixed */ public function edit() { $this->data['ids'] = func_get_args(); $this->mode = 'edit'; $this->model = $this->repo->findById($this->getCurrentId()); $this->data['title'] = $this->descriptor === 'id' ? $this->singular . ' bewerken' : strip_tags(translateAttribute($this->model->{$this->descriptor})); $this->initAttributes(); return $this->setupView('form'); }
/** * @param $name * * @return string */ protected function getLabel($name) { $label = translateAttribute($name); $label = str_replace('_', ' ', $label); if ($this->required) { $label .= ' *'; } return $label; }