Collective\Html\FormBuilder::model PHP Метод

model() публичный Метод

Create a new model based form builder.
public model ( mixed $model, array $options = [] ) : Illuminate\Support\HtmlString
$model mixed
$options array
Результат Illuminate\Support\HtmlString
    public function model($model, array $options = [])
    {
        $this->model = $model;
        return $this->open($options);
    }

Usage Example

Пример #1
0
 /**
  * Open a form configured for model binding.
  *
  * @param  array  $options
  * @return string
  */
 protected function model($options)
 {
     $model = $options['model'];
     if (isset($options['url'])) {
         // If we're explicity passed a URL, we'll use that.
         array_forget($options, ['update', 'store']);
         $options['method'] = isset($options['method']) ? $options['method'] : 'GET';
         return $this->form->model($model, $options);
     }
     if (!is_null($options['model']) && $options['model']->exists) {
         // If the form is passed a model, we'll use the update route to update
         // the model using the PUT method.
         $route = Str::contains($options['update'], '@') ? 'action' : 'route';
         $options[$route] = [$options['update'], $options['model']->getRouteKey()];
         $options['method'] = 'PUT';
     } else {
         // Otherwise, we're storing a brand new model using the POST method.
         $route = Str::contains($options['store'], '@') ? 'action' : 'route';
         $options[$route] = $options['store'];
         $options['method'] = 'POST';
     }
     // Forget the routes provided to the input.
     array_forget($options, ['model', 'update', 'store']);
     return $this->form->model($model, $options);
 }
All Usage Examples Of Collective\Html\FormBuilder::model