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