item transformer doesn't accept null

This commit is contained in:
denisdulici 2017-10-09 11:59:58 +03:00
parent f8ce9ffd32
commit f1cd07dd70
3 changed files with 31 additions and 15 deletions

View File

@ -51,10 +51,14 @@ class Payment extends TransformerAbstract
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
* @return mixed
*/
public function includeVendor(Model $model)
{
if (!$model->vendor) {
return $this->null();
}
return $this->item($model->vendor, new Vendor());
}

View File

@ -51,10 +51,14 @@ class Revenue extends TransformerAbstract
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
* @return mixed
*/
public function includeCustomer(Model $model)
{
if (!$model->customer) {
return $this->null();
}
return $this->item($model->customer, new Customer());
}

View File

@ -40,19 +40,27 @@ class Item extends TransformerAbstract
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
* @return mixed
*/
public function includeTax(Model $model)
{
if (!$model->tax) {
return $this->null();
}
return $this->item($model->tax, new Tax());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
* @return mixed
*/
public function includeCategory(Model $model)
{
if (!$model->category) {
return $this->null();
}
return $this->item($model->category, new Category());
}
}