101 lines
2.1 KiB
PHP
101 lines
2.1 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;
|
|
use Tymon\JWTAuth\Contracts\JWTSubject;
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'nama',
|
|
'email',
|
|
'password',
|
|
'role_id',
|
|
'alamat',
|
|
'foto_ktp',
|
|
'foto_wajah',
|
|
'nohp',
|
|
'nik',
|
|
'gender',
|
|
'status',
|
|
];
|
|
|
|
/**
|
|
* 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',
|
|
'password' => 'hashed',
|
|
'id' => 'string',
|
|
];
|
|
|
|
//JWT
|
|
|
|
/**
|
|
* Get the identifier that will be stored in the subject claim of the JWT.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function getJWTIdentifier()
|
|
{
|
|
return $this->getKey();
|
|
}
|
|
|
|
/**
|
|
* Return a key value array, containing any custom claims to be added to the JWT.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getJWTCustomClaims()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
//JWT
|
|
|
|
|
|
//Relasi
|
|
public function pemilik_kontak(){
|
|
return $this->hasMany(Contact::class, 'email', 'pemilik_kontak');
|
|
}
|
|
|
|
public function relasi_kontak(){
|
|
return $this->hasMany(Contact::class, 'email', 'relasi_kontak');
|
|
}
|
|
|
|
public function pembeli(){
|
|
return $this->hasMany(Transaction::class, 'email', 'pembeli');
|
|
}
|
|
|
|
public function penjual(){
|
|
return $this->hasMany(Transaction::class, 'email', 'penjual');
|
|
}
|
|
//Relasi
|
|
|
|
}
|