Middleware se encarga de validar que usuario pertenezca al restaurant
This commit is contained in:
@@ -43,6 +43,10 @@ class Usuario extends Model {
|
||||
return in_array($role, $this->roles);
|
||||
}
|
||||
|
||||
public function isOnRestaurante($restaurante) {
|
||||
return $this->restaurantes()->where('id', $restaurante->id)->count() > 0;
|
||||
}
|
||||
|
||||
public function restaurantes() {
|
||||
return $this->belongsToMany(Restaurante::class, 'usuarios_restaurantes', 'usuario_id', 'restaurante_id');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user