PHP Class app\Category

Inheritance: extends Illuminate\Database\Eloquent\Model
Show file Open project: ant-vel/antVel Class Usage Examples

Protected Properties

Property Type Description
$appends array The attributes to append.
$family_tree boolean Select if return the categories family tree.
$fillable array The attributes that are mass assignable.
$table string The database table used by the model.

Public Methods

Method Description
category ( )
getChildsAttribute ( ) : collection Return a collection of a category's childs, or null if don't have.
getParentAttribute ( ) : app\category Return the parent of a category, or null if don't have.
getParentTreeAttribute ( ) : app\category Return the the full tree of parents of a category, or null if don't have.
hasChildren ( )
hasChilds ( )
hasParent ( )
newCollection ( array $models = [] ) : App\Collection\Categories Override Collection Method.
parentsTree ( [int] $id, [array] &$array, [array] $fields = ['id', 'category_id', 'name'] ) parentsTree Retrieve all the categories parents of one passed through parameter, checking data from bottom to top.
product ( )
progeny ( [int] $id, &$list, [array] $fields = ['id', 'name'] ) progeny Retrieve all the categories children of one passed through parameter, checking data from bottom to top.
scopeActives ( $query )
scopeByName ( $query )
scopeChildsOf ( $query, $id ) scopeChildsOf Return all the children of a category. If the id is empty, 'parents' or 'others' will be given.
scopeFull ( [type] $query ) : [type] scopeFull Retrieve the total of products contained in a category.
scopeGroup ( $query )
scopeInactives ( $query )
scopeLightSelection ( [object] $query ) scopeLightSelection Retrieve build the query select as scope.
scopeMothers ( [type] $query ) : [type] scopeMothers Retrieve the main categories.
scopeSearch ( $query, $name )
scopeStore ( $query )
withChilds ( )
withFamilyTree ( $value = true )
withParentTree ( )

Method Details

category() public method

public category ( )

getChildsAttribute() public method

Return a collection of a category's childs, or null if don't have.
public getChildsAttribute ( ) : collection
return collection

getParentAttribute() public method

Return the parent of a category, or null if don't have.
public getParentAttribute ( ) : app\category
return app\category model

getParentTreeAttribute() public method

The tree contains the master parent, and a child attribute that contains next element, up to.
public getParentTreeAttribute ( ) : app\category
return app\category model

hasChildren() public method

public hasChildren ( )

hasChilds() public method

public hasChilds ( )

hasParent() public method

public hasParent ( )

newCollection() public method

Override Collection Method.
public newCollection ( array $models = [] ) : App\Collection\Categories
$models array
return App\Collection\Categories Collection

parentsTree() public static method

parentsTree Retrieve all the categories parents of one passed through parameter, checking data from bottom to top.
public static parentsTree ( [int] $id, [array] &$array, [array] $fields = ['id', 'category_id', 'name'] )
$id [int]
$array [array]
$fields [array]

product() public method

public product ( )

progeny() public static method

progeny Retrieve all the categories children of one passed through parameter, checking data from bottom to top.
public static progeny ( [int] $id, &$list, [array] $fields = ['id', 'name'] )
$id [int]
$fields [array]

scopeActives() public method

public scopeActives ( $query )

scopeByName() public method

public scopeByName ( $query )

scopeChildsOf() public method

scopeChildsOf Return all the children of a category. If the id is empty, 'parents' or 'others' will be given.
public scopeChildsOf ( $query, $id )
$query
$id that can be either category id, empty value, 'parents' or 'mothers'

scopeFull() public method

scopeFull Retrieve the total of products contained in a category.
public scopeFull ( [type] $query ) : [type]
$query [type]
return [type]

scopeGroup() public method

public scopeGroup ( $query )

scopeInactives() public method

public scopeInactives ( $query )

scopeLightSelection() public method

scopeLightSelection Retrieve build the query select as scope.
public scopeLightSelection ( [object] $query )
$query [object]

scopeMothers() public method

scopeMothers Retrieve the main categories.
public scopeMothers ( [type] $query ) : [type]
$query [type]
return [type]

scopeSearch() public method

public scopeSearch ( $query, $name )

scopeStore() public method

public scopeStore ( $query )

withChilds() public method

public withChilds ( )

withFamilyTree() public method

public withFamilyTree ( $value = true )

withParentTree() public method

public withParentTree ( )

Property Details

$appends protected property

The attributes to append.
protected array $appends
return array

$family_tree protected property

Select if return the categories family tree.
protected bool $family_tree
return boolean

$fillable protected property

The attributes that are mass assignable.
protected array $fillable
return array

$table protected property

The database table used by the model.
protected string $table
return string