| Code Coverage
| Classes and Traits | Functions and Methods | Lines
Total | 100.00% covered (success) | 100.00% | 1 / 1 | 100.00% covered (success) | 100.00% | 2 / 2 | CRAP | 100.00% covered (success) | 100.00% | 2 / 2
City | 100.00% covered (success) | 100.00% | 1 / 1 | 100.00% covered (success) | 100.00% | 2 / 2 | 3 | 100.00% covered (success) | 100.00% | 2 / 2
province | 100.00% covered (success) | 100.00% | 1 / 1 | 1 | 100.00% covered (success) | 100.00% | 1 / 1
getProvinceNameAttribute | 100.00% covered (success) | 100.00% | 1 / 1 | 2 | 100.00% covered (success) | 100.00% | 1 / 1

1 | <?php
2 |
3 | namespace App;
4 |
5 | use Illuminate\Database\Eloquent\Model;
6 |
7 | class City extends Model
8 | {
9 | protected $fillable=[
10 | 'province_id','name'
11 | ];
12 |
13 | protected $appends=[
14 | 'province_name'
15 | ];
16 |
17 | public function province(){
18 | return $this->belongsTo('App\Province','province_id','id');
19 | }
20 |
21 | public function getProvinceNameAttribute(){
22 | return $this['province']? $this['province']['name']:null;
23 | }
24 |
25 | }