コード例 #1
0
 /**
  * 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();
 }
コード例 #2
0
 /**
  * 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();
 }
コード例 #3
0
 /**
  * getDisplayValue
  *
  * @param Model $model
  *
  * @return mixed Value.
  */
 public function getDisplayValue(Model $model)
 {
     return $model->{$this->name} ? translateAttribute('yes') : translateAttribute('no');
 }
コード例 #4
0
 /**
  * @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');
 }
コード例 #5
0
ファイル: Attribute.php プロジェクト: wearejust/shapeshifter
 /**
  * @param $name
  *
  * @return string
  */
 protected function getLabel($name)
 {
     $label = translateAttribute($name);
     $label = str_replace('_', ' ', $label);
     if ($this->required) {
         $label .= ' *';
     }
     return $label;
 }