- Fix vider la barre de recherche quand on clique sur "Réinitialiser" - Fix script index ElasticMedia + ajout condition sur l'existence d'un index - Ajout de la requete Elasticsearch dans MediaController
134 lines
2.6 KiB
PHP
134 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
// protected $fillable = [
|
|
// 'name', 'email', 'password',
|
|
// ];
|
|
|
|
/**
|
|
* The attributes that should be hidden for arrays.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'password', 'remember_token',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'email_verified_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* @param string|array $roles
|
|
*/
|
|
public function authorizeRoles($roles){
|
|
if (is_array($roles)) {
|
|
return in_array($this->role, $roles) ||
|
|
abort(401, 'Cette action n\'est pas autorisée.');
|
|
}
|
|
return $this->role == $roles ||
|
|
abort(401, 'Cette action n\'est pas autorisée.');
|
|
}
|
|
|
|
/**
|
|
* Check one role
|
|
* @param string $role
|
|
*/
|
|
public function hasRole($roles) {
|
|
if (is_array($roles)) {
|
|
return in_array($this->role, $roles);
|
|
}
|
|
return $this->role == $roles;
|
|
}
|
|
|
|
/**
|
|
* get one role label
|
|
* @param string $role
|
|
*/
|
|
public function getRoleLabel() {
|
|
return config('roles.label.'.$this->role);
|
|
}
|
|
|
|
/**
|
|
* The marques that belong to the user.
|
|
*/
|
|
public function marques()
|
|
{
|
|
return $this->belongsToMany('App\Models\Marque', 'marques_users', 'user_id', 'marque_id');
|
|
}
|
|
|
|
/**
|
|
* The dossiers that belong to the user.
|
|
*/
|
|
public function dossiers()
|
|
{
|
|
return $this->belongsToMany('App\Models\Dossier', 'dossiers_users', 'user_id', 'dossier_id');
|
|
}
|
|
|
|
/**
|
|
* The sujet that belong to the user.
|
|
*/
|
|
public function sujets()
|
|
{
|
|
return $this->belongsToMany('App\Models\Sujet', 'sujets_users', 'user_id', 'sujet_id');
|
|
}
|
|
|
|
/**
|
|
* Get the medias for the user.
|
|
*/
|
|
public function medias()
|
|
{
|
|
return $this->hasMany('App\Models\Media');
|
|
}
|
|
|
|
/**
|
|
* Get the historiques for the user.
|
|
*/
|
|
public function historiques()
|
|
{
|
|
return $this->hasMany('App\Models\Historique');
|
|
}
|
|
|
|
/**
|
|
* Get the recherches for the user.
|
|
*/
|
|
public function recherches()
|
|
{
|
|
return $this->hasMany('App\Models\Recherche');
|
|
}
|
|
|
|
/**
|
|
* Get the paniers for the user.
|
|
*/
|
|
public function paniersOwner()
|
|
{
|
|
return $this->hasMany('App\Models\Panier', 'owner');
|
|
}
|
|
|
|
/**
|
|
* The paniers that belong to the user.
|
|
*/
|
|
public function paniersFavoris()
|
|
{
|
|
return $this->belongsToMany('App\Models\Panier', 'paniers_users', 'user_id', 'panier_id');
|
|
}
|
|
}
|