✨ Permet la mise à jour du profil
La mise à jour de l'avatar fonctionne à moitié Pour #12
This commit is contained in:
42
app/User.php
42
app/User.php
@@ -5,10 +5,14 @@ namespace App;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Image\Exceptions\InvalidManipulation;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
|
||||
use Spatie\MediaLibrary\Models\Media;
|
||||
|
||||
class User extends Authenticatable
|
||||
class User extends Authenticatable implements HasMedia
|
||||
{
|
||||
use Notifiable;
|
||||
use Notifiable, HasMediaTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -16,7 +20,7 @@ class User extends Authenticatable
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
'name', 'email', 'password', 'notification_hour', 'encrypt_messages', 'avatar',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -28,14 +32,18 @@ class User extends Authenticatable
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'created_at', 'updated_at', 'email_verified_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
// protected $casts = [
|
||||
// 'email_verified_at' => 'datetime',
|
||||
// ];
|
||||
|
||||
public function getFolder()
|
||||
{
|
||||
@@ -50,4 +58,26 @@ class User extends Authenticatable
|
||||
{
|
||||
return (bool) $this->encrypt_messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Media|null $media
|
||||
*/
|
||||
public function registerMediaConversions(Media $media = null)
|
||||
{
|
||||
try {
|
||||
$this->addMediaConversion('thumb')
|
||||
->width(50)
|
||||
->height(50);
|
||||
} catch (InvalidManipulation $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $alias
|
||||
* @return string
|
||||
*/
|
||||
public function getAvatar($alias = 'thumb')
|
||||
{
|
||||
return $this->getFirstMediaUrl('avatars');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user