ispt4.0_laravel/app/Models/User.php
ygbanzato 3db065ae53 updating best practices in project models and controllers, and linking tables.
- Creation of controller : CreateProject, for creation of the company works.
- Controller : ProjectDatacontroller to manage data of the equipments and installations in general.
2023-06-03 19:01:17 +01:00

71 lines
1.5 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 Illuminate\Contracts\Auth\MustVerifyEmail;
class User extends Authenticatable
// implements MustVerifyEmail
{
use HasApiTokens, HasFactory, Notifiable;
protected $table = 'users';
protected $primaryKey = 'user_id';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'user_type',
'user_phone',
'user_nif'
];
/**
* 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',
];
// public function typeUser(){
// return $this->belongsTo(TypeUser::class, 'type_users', 'type_user_id');
// }
public function userType() {
return $this->belongsTo(TypeUser::class, 'type_users', 'type_user_id');
}
public function plants(){
return $this->hasMany(Plant::class,'user_id', 'user_id');
}
}