Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
3 / 3 |
SponsorGroup | |
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\SiteGeneratorSponsors\Models; |
4 | |
5 | use Illuminate\Database\Eloquent\Model; |
6 | |
7 | class SponsorGroup extends Model |
8 | { |
9 | protected $connection = 'siteGeneratorSponsors'; |
10 | protected $casts = ['sponsors' => '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 | |
35 | } |