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