<?php
// ════════════════════════════════════════════════════════
// User.php
// ════════════════════════════════════════════════════════
namespace App\Models;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    protected $table      = 'users';
    protected $connection = 'default';
    public $timestamps    = false;

    protected $fillable = [
        'email', 'password', 'role', 'nom', 'prenom',
        'atelier_id', 'presta_customer_id',
        'strava_connected', 'strava_id',
        'strava_access_token', 'strava_refresh_token', 'strava_token_expires',
        'reset_token', 'reset_expires', 'actif', 'anonymized_at',
        'date_inscription', 'derniere_connexion',
    ];

    protected $hidden = ['password', 'strava_access_token', 'strava_refresh_token', 'reset_token'];

    public function chronos()   { return $this->hasMany(Chrono::class, 'user_id'); }
    public function commandes() { return $this->hasMany(Commande::class, 'user_id'); }
    public function sessions()  { return $this->hasMany(Session::class, 'user_id'); }
    public function atelier()   { return $this->belongsTo(Atelier::class, 'atelier_id'); }
}
