moved folders to common directory
This commit is contained in:
33
app/Transformers/Common/Company.php
Normal file
33
app/Transformers/Common/Company.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Common;
|
||||
|
||||
use App\Models\Common\Company as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Company extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'name' => $model->company_name,
|
||||
'email' => $model->company_email,
|
||||
'domain' => $model->domain,
|
||||
'address' => $model->company_address,
|
||||
'logo' => $model->company_logo,
|
||||
'default_account' => $model->default_account,
|
||||
'default_currency' => $model->default_currency,
|
||||
'default_tax' => $model->default_tax,
|
||||
'default_payment_method' => $model->default_payment_method,
|
||||
'default_language' => $model->default_language,
|
||||
'enabled' => $model->enabled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
66
app/Transformers/Common/Item.php
Normal file
66
app/Transformers/Common/Item.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Common;
|
||||
|
||||
use App\Transformers\Setting\Category;
|
||||
use App\Transformers\Setting\Tax;
|
||||
use App\Models\Common\Item as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Item extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['tax', 'category'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'name' => $model->name,
|
||||
'sku' => $model->sku,
|
||||
'description' => $model->description,
|
||||
'sale_price' => $model->sale_price,
|
||||
'purchase_price' => $model->purchase_price,
|
||||
'quantity' => $model->quantity,
|
||||
'category_id' => $model->category_id,
|
||||
'tax_id' => $model->tax_id,
|
||||
'picture' => $model->picture,
|
||||
'enabled' => $model->enabled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function includeTax(Model $model)
|
||||
{
|
||||
if (!$model->tax) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
return $this->item($model->tax, new Tax());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function includeCategory(Model $model)
|
||||
{
|
||||
if (!$model->category) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
return $this->item($model->category, new Category());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user