2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\Transformers;
|
2016-02-03 04:21:13 +01:00
|
|
|
|
|
|
|
use App\Models\Credit;
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
2017-11-06 15:36:36 +01:00
|
|
|
* @SWG\Definition(definition="Credit", required={"client_id"}, @SWG\Xml(name="Credit"))
|
2016-07-03 18:11:58 +02:00
|
|
|
*/
|
2016-02-03 04:21:13 +01:00
|
|
|
class CreditTransformer extends EntityTransformer
|
|
|
|
{
|
2017-11-06 15:36:36 +01:00
|
|
|
/**
|
|
|
|
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
|
|
|
|
* @SWG\Property(property="amount", type="number", format="float", example=10, readOnly=true)
|
|
|
|
* @SWG\Property(property="client_id", type="integer", example=1)
|
|
|
|
* @SWG\Property(property="private_notes", type="string", example="Notes...")
|
|
|
|
* @SWG\Property(property="public_notes", type="string", example="Notes...")
|
|
|
|
*/
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @param Credit $credit
|
2017-01-30 20:40:43 +01:00
|
|
|
*
|
2016-07-03 18:11:58 +02:00
|
|
|
* @return array
|
|
|
|
*/
|
2016-02-03 04:21:13 +01:00
|
|
|
public function transform(Credit $credit)
|
|
|
|
{
|
2016-05-03 22:02:29 +02:00
|
|
|
return array_merge($this->getDefaults($credit), [
|
2016-02-03 04:21:13 +01:00
|
|
|
'id' => (int) $credit->public_id,
|
|
|
|
'amount' => (float) $credit->amount,
|
|
|
|
'balance' => (float) $credit->balance,
|
|
|
|
'updated_at' => $this->getTimestamp($credit->updated_at),
|
|
|
|
'archived_at' => $this->getTimestamp($credit->deleted_at),
|
|
|
|
'is_deleted' => (bool) $credit->is_deleted,
|
|
|
|
'credit_date' => $credit->credit_date,
|
|
|
|
'credit_number' => $credit->credit_number,
|
|
|
|
'private_notes' => $credit->private_notes,
|
2017-03-30 10:46:52 +02:00
|
|
|
'public_notes' => $credit->public_notes,
|
2017-06-06 11:16:44 +02:00
|
|
|
'client_id' => $credit->client->public_id,
|
2016-05-03 22:02:29 +02:00
|
|
|
]);
|
2016-02-03 04:21:13 +01:00
|
|
|
}
|
2017-01-30 17:05:31 +01:00
|
|
|
}
|