MIF_E31211871/Laravel/app/Models/User.php

81 lines
1.7 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $table = 'user';
protected $primaryKey = 'id_user';
public $incrementing = false;
protected $fillable = [
'id_user',
'nama',
'no_telepon',
'email_verified',
'kode_verified',
'token',
'token_fcm',
'alamat',
'longitude',
'latitude',
'email',
'password',
'id_role', // customer
'foto',
'created_at',
'updated_at',
];
// Relationship dengan tabel Role
public function role()
{
return $this->belongsTo(Role::class, 'id_role');
}
// Relationship dengan tabel Pickup (sebagai customer)
public function pickupsAsCustomer()
{
return $this->hasMany(Pickup::class, 'id_customer');
}
// Relationship dengan tabel Pickup (sebagai pegawai)
public function pickupsAsPegawai()
{
return $this->hasMany(Pickup::class, 'id_pegawai');
}
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}