Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
3 / 3 |
| OfferGroup | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
3 / 3 |
| resolveRouteBinding | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| getTextAttribute | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| serializeDate | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Qmp\Laravel\SiteGeneratorOffers\Models; |
| 4 | |
| 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | |
| 7 | class OfferGroup extends Model |
| 8 | { |
| 9 | protected $connection = 'siteGeneratorOffers'; |
| 10 | protected $casts = ['offers' => 'array']; |
| 11 | protected $appends = ['text']; |
| 12 | protected $hidden = ['name']; |
| 13 | |
| 14 | public function resolveRouteBinding($value, $field = null) |
| 15 | { |
| 16 | return $this->where('id', $value)->first() ?? abort(422, 'Datas not found'); |
| 17 | } |
| 18 | |
| 19 | public function getTextAttribute() |
| 20 | { |
| 21 | return $this->attributes['name']; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Prepare a date for array / JSON serialization. |
| 26 | * |
| 27 | * @param \DateTimeInterface $date |
| 28 | * @return string |
| 29 | */ |
| 30 | protected function serializeDate(\DateTimeInterface $date) |
| 31 | { |
| 32 | return $date->format('Y-m-d H:i:s'); |
| 33 | } |
| 34 | } |