Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| UserRole | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| user | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| role | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Models\Auth; |
| 4 | |
| 5 | use App\Observers\UserRoleObserver; |
| 6 | use Illuminate\Database\Eloquent\Attributes\ObservedBy; |
| 7 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 8 | use Illuminate\Notifications\Notifiable; |
| 9 | use MongoDB\Laravel\Eloquent\Model; |
| 10 | |
| 11 | #[ObservedBy([UserRoleObserver::class])] |
| 12 | class UserRole extends Model |
| 13 | { |
| 14 | use HasFactory, Notifiable; |
| 15 | |
| 16 | protected $table = 'role_user'; |
| 17 | |
| 18 | protected $with = ['user', 'role']; |
| 19 | |
| 20 | protected $fillable = [ |
| 21 | 'user_id', |
| 22 | 'role_id', |
| 23 | ]; |
| 24 | |
| 25 | public function user() |
| 26 | { |
| 27 | return $this->belongsTo(User::class); |
| 28 | } |
| 29 | |
| 30 | public function role() |
| 31 | { |
| 32 | return $this->hasOne(Role::class, '_id', 'role_id'); |
| 33 | } |
| 34 | } |