PHP Class Flugg\Responder\ResourceFactory

Author: Alexander Tømmerås ([email protected])
Datei anzeigen Open project: flugger/laravel-responder Class Usage Examples

Public Methods

Method Description
make ( mixed | null $data = null ) : League\Fractal\Resource\ResourceInterface Build a resource instance from the given data.

Protected Methods

Method Description
getMakeMethod ( mixed $data ) : string Resolve which make method to call from the given date type.
makeFromArray ( array $array ) : League\Fractal\Resource\ResourceInterface Make resource from a collection of Eloquent models.
makeFromBuilder ( Builder $query ) : League\Fractal\Resource\ResourceInterface Make resource from an Eloquent query builder.
makeFromCollection ( Collection $collection ) : League\Fractal\Resource\ResourceInterface Make resource from a collection.
makeFromModel ( Model $model ) : League\Fractal\Resource\ResourceInterface Make resource from an Eloquent model.
makeFromPaginator ( Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator ) : League\Fractal\Resource\ResourceInterface Make resource from an Eloquent paginator.
makeFromPivot ( Illuminate\Database\Eloquent\Relations\Pivot $pivot ) : League\Fractal\Resource\ResourceInterface Make resource from an Eloquent pivot table.
makeFromRelation ( Illuminate\Database\Eloquent\Relations\Relation $relation ) : League\Fractal\Resource\ResourceInterface Make resource from an Eloquent query builder.

Method Details

getMakeMethod() protected method

Resolve which make method to call from the given date type.
protected getMakeMethod ( mixed $data ) : string
$data mixed
return string

make() public method

Build a resource instance from the given data.
public make ( mixed | null $data = null ) : League\Fractal\Resource\ResourceInterface
$data mixed | null
return League\Fractal\Resource\ResourceInterface

makeFromArray() protected method

Make resource from a collection of Eloquent models.
protected makeFromArray ( array $array ) : League\Fractal\Resource\ResourceInterface
$array array
return League\Fractal\Resource\ResourceInterface

makeFromBuilder() protected method

Make resource from an Eloquent query builder.
protected makeFromBuilder ( Builder $query ) : League\Fractal\Resource\ResourceInterface
$query Illuminate\Database\Eloquent\Builder
return League\Fractal\Resource\ResourceInterface

makeFromCollection() protected method

Make resource from a collection.
protected makeFromCollection ( Collection $collection ) : League\Fractal\Resource\ResourceInterface
$collection Illuminate\Support\Collection
return League\Fractal\Resource\ResourceInterface

makeFromModel() protected method

Make resource from an Eloquent model.
protected makeFromModel ( Model $model ) : League\Fractal\Resource\ResourceInterface
$model Illuminate\Database\Eloquent\Model
return League\Fractal\Resource\ResourceInterface

makeFromPaginator() protected method

Make resource from an Eloquent paginator.
protected makeFromPaginator ( Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator ) : League\Fractal\Resource\ResourceInterface
$paginator Illuminate\Contracts\Pagination\LengthAwarePaginator
return League\Fractal\Resource\ResourceInterface

makeFromPivot() protected method

Make resource from an Eloquent pivot table.
protected makeFromPivot ( Illuminate\Database\Eloquent\Relations\Pivot $pivot ) : League\Fractal\Resource\ResourceInterface
$pivot Illuminate\Database\Eloquent\Relations\Pivot
return League\Fractal\Resource\ResourceInterface

makeFromRelation() protected method

Make resource from an Eloquent query builder.
protected makeFromRelation ( Illuminate\Database\Eloquent\Relations\Relation $relation ) : League\Fractal\Resource\ResourceInterface
$relation Illuminate\Database\Eloquent\Relations\Relation
return League\Fractal\Resource\ResourceInterface