83 lines
1.6 KiB
PHP
83 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
|
|
class User extends Authenticatable implements MustVerifyEmail
|
|
{
|
|
use HasFactory, Notifiable;
|
|
|
|
/**
|
|
* UUID settings
|
|
*/
|
|
public $incrementing = false;
|
|
protected $keyType = 'string';
|
|
|
|
/**
|
|
* Boot function untuk generate UUID otomatis
|
|
*/
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function ($user) {
|
|
if (!$user->id) {
|
|
$user->id = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Mass assignable
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
'nama_pangkalan',
|
|
'alamat',
|
|
'role',
|
|
];
|
|
|
|
/**
|
|
* Hidden attributes
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* Casts
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
}
|
|
|
|
public function dataPenjualan()
|
|
{
|
|
return $this->hasMany(DataPenjualan::class, 'user_id');
|
|
}
|
|
|
|
public function hasilPrediksis() {
|
|
return $this->hasMany(HasilPrediksi::class, 'user_id');
|
|
}
|
|
|
|
public function helpdesks() {
|
|
return $this->hasMany(Helpdesk::class, 'user_id');
|
|
}
|
|
|
|
public function hasilPrediksi()
|
|
{
|
|
return $this->hasMany(HasilPrediksi::class, 'user_id');
|
|
}
|
|
} |