Model Helper
This helper will provide information about specific model, which can be loaded from full classname ModelHelper::fromClass() or from an model's file ModelHelper::fromFile().
Model Helper is "macroable" and "collectable", which allows you to run batch methods and collect output with ModelHelper::fromClass('App\User')->collect('name', 'namespace')
Construct from File
/**
* Load a model from file
* @param string $path
* @return Model
*/
ModelHelper::fromFile(): voidConstruct from Class
/**
* Load a model from class
* @param string $class
* @return Model
*/
ModelHelper::fromClass(): voidReflection
/**
* Get class reflection
* @return ReflectionClass
* @throws \ReflectionException
*/
ModelHelper::reflection(): voidParent
/**
* Get immediate parent of a model class
* Note that this might not be useful as user can extend from custom 'model' class not Laravel one.
* @return string
*/
ModelHelper::parent(): voidClass
/**
* Get model's class (namespace + name)
* @return string
*/
ModelHelper::class(): voidName
/**
* Get model's name without namespace
* @return string
*/
ModelHelper::name(): voidNamespace
/**
* Get models's namespace
* @return string
*/
ModelHelper::namespace(): voidInstance
/**
* Initiate a new instance of a model
* @return Eloquent
*/
ModelHelper::instance(): voidPrimary
/**
* Get primary key for a model
* @return string
*/
ModelHelper::primary(): voidTable
/**
* Get model's table
* @return string
*/
ModelHelper::table(): voidHidden
/**
* Get hidden attributes
* @return Collection
*/
ModelHelper::hidden(): voidFillable
/**
* Get fillable attributes
* @return Collection
*/
ModelHelper::fillable(): voidRequest
/**
* Get FormRequest for this model if one exists
* @return null|FormRequest
*/
ModelHelper::fillable(): voidAttributes
/**
* Get model's attributes
* @return Collection
*/
ModelHelper::attributes(): voidRules
/**
* Build validation rules
* @param bool $fillableOnly: true
* @param bool $deepAnalysis: false
* @return Collection
*/
ModelHelper::rules(): voidRelationships
/**
* Get model's relationships
* @return Collection
*/
ModelHelper::relationships(): voidFields
/**
* Get attribute and relationship fields (either native HTML or Vue extended)
* This method basically maps attribute type to corresponding field/input type.
* @param bool $fillable: default false
* @param bool $extended: default false
* @return Collection
*/
ModelHelper::fields(): void