PHP Class Encore\Admin\Form

Show file Open project: z-song/laravel-admin Class Usage Examples

Protected Properties

Property Type Description
$builder Encore\Admin\Form\Builder
$callable callable
$inputs array Input data.
$model Eloquent model of the form.
$relations array Data for save to model's relations from input.
$saved Closure Saved callback.
$saving Closure Saving callback.
$updates array Data for save to current model from input.
$validator Illuminate\Validation\Validator

Public Methods

Method Description
__call ( string $method, array $arguments ) : Field | void Generate a Field object and add to form builder if Field exists.
__construct ( $model, Closure $callback )
__get ( string $name ) : array | mixed Getter.
__set ( string $name, $value ) Setter.
__toString ( ) : string Render the contents of the form when casting to string.
builder ( ) : Builder
destroy ( $id ) : mixed Destroy data entity and remove files.
edit ( $id ) Generate a edit form.
findFieldClass ( $method )
getRelations ( ) : array Get all relations of model from callable.
input ( string $key, null $value = null ) : array | mixed Get or set input data.
model ( ) : Model
pushField ( Field $field )
render ( ) : string Render the form contents.
resource ( ) : string Get current resource route url.
saved ( Closure $callback ) : void Set saved callback.
saving ( Closure $callback ) : void Set saving callback.
store ( ) Store a new record.
update ( $id )
view ( $id )

Protected Methods

Method Description
complete ( Closure $callback = null ) : void Callback after saving a Model.
deleteFilesAndImages ( $id ) Remove files or images in record.
getDataByColumn ( array $data, string | array $columns ) : array | mixed
getFieldByColumn ( $column ) : mixed Find field object by column.
prepare ( array $data = [], Closure $callback = null ) Prepare input data for insert or update.
prepareInsert ( $inserts ) : array Prepare input data for insert.
prepareUpdate ( $updates ) : array Prepare input data for update.
saveRelation ( array $relations ) : void Save relations data.
setFieldOriginalValue ( ) : void Set original data for each field.
setFieldValue ( $id ) : void Set all fields value in form.
setUp ( ) Set up the form.
updateRelation ( array $relations ) : void Update relation data.
validate ( $input ) : boolean Validate input data.

Method Details

__call() public method

Generate a Field object and add to form builder if Field exists.
public __call ( string $method, array $arguments ) : Field | void
$method string
$arguments array
return Encore\Admin\Form\Field | void

__construct() public method

public __construct ( $model, Closure $callback )
$callback Closure

__get() public method

Getter.
public __get ( string $name ) : array | mixed
$name string
return array | mixed

__set() public method

Setter.
public __set ( string $name, $value )
$name string
$value

__toString() public method

Render the contents of the form when casting to string.
public __toString ( ) : string
return string

builder() public method

public builder ( ) : Builder
return Encore\Admin\Form\Builder

complete() protected method

Callback after saving a Model.
protected complete ( Closure $callback = null ) : void
$callback Closure
return void

deleteFilesAndImages() protected method

Remove files or images in record.
protected deleteFilesAndImages ( $id )
$id

destroy() public method

Destroy data entity and remove files.
public destroy ( $id ) : mixed
$id
return mixed

edit() public method

Generate a edit form.
public edit ( $id )
$id

findFieldClass() public static method

public static findFieldClass ( $method )

getDataByColumn() protected static method

protected static getDataByColumn ( array $data, string | array $columns ) : array | mixed
$data array
$columns string | array
return array | mixed

getFieldByColumn() protected method

Find field object by column.
protected getFieldByColumn ( $column ) : mixed
$column
return mixed

getRelations() public method

Get all relations of model from callable.
public getRelations ( ) : array
return array

input() public method

Get or set input data.
public input ( string $key, null $value = null ) : array | mixed
$key string
$value null
return array | mixed

model() public method

public model ( ) : Model
return Illuminate\Database\Eloquent\Model

prepare() protected method

Prepare input data for insert or update.
protected prepare ( array $data = [], Closure $callback = null )
$data array
$callback Closure

prepareInsert() protected method

Prepare input data for insert.
protected prepareInsert ( $inserts ) : array
$inserts
return array

prepareUpdate() protected method

Prepare input data for update.
protected prepareUpdate ( $updates ) : array
$updates
return array

pushField() public method

public pushField ( Field $field )
$field Encore\Admin\Form\Field

render() public method

Render the form contents.
public render ( ) : string
return string

resource() public method

Get current resource route url.
public resource ( ) : string
return string

saveRelation() protected method

Save relations data.
protected saveRelation ( array $relations ) : void
$relations array
return void

saved() public method

Set saved callback.
public saved ( Closure $callback ) : void
$callback Closure
return void

saving() public method

Set saving callback.
public saving ( Closure $callback ) : void
$callback Closure
return void

setFieldOriginalValue() protected method

Set original data for each field.
protected setFieldOriginalValue ( ) : void
return void

setFieldValue() protected method

Set all fields value in form.
protected setFieldValue ( $id ) : void
$id
return void

setUp() protected method

Set up the form.
protected setUp ( )

store() public method

Store a new record.
public store ( )

update() public method

public update ( $id )
$id

updateRelation() protected method

Update relation data.
protected updateRelation ( array $relations ) : void
$relations array
return void

validate() protected method

Validate input data.
protected validate ( $input ) : boolean
$input
return boolean

view() public method

public view ( $id )
$id

Property Details

$builder protected property

protected Builder,Encore\Admin\Form $builder
return Encore\Admin\Form\Builder

$callable protected property

protected callable $callable
return callable

$inputs protected property

Input data.
protected array $inputs
return array

$model protected property

Eloquent model of the form.
protected $model

$relations protected property

Data for save to model's relations from input.
protected array $relations
return array

$saved protected property

Saved callback.
protected Closure $saved
return Closure

$saving protected property

Saving callback.
protected Closure $saving
return Closure

$updates protected property

Data for save to current model from input.
protected array $updates
return array

$validator protected property

protected Validator,Illuminate\Validation $validator
return Illuminate\Validation\Validator