mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 22:39:34 +00:00
61 lines
1.2 KiB
PHP
61 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
use Laravel\Sanctum\PersonalAccessToken;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
];
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
public function teams()
|
|
{
|
|
return $this->belongsToMany(Team::class);
|
|
}
|
|
|
|
public function timesheets()
|
|
{
|
|
return $this->hasMany(Timesheet::class);
|
|
}
|
|
|
|
public function subtasks()
|
|
{
|
|
return $this->hasMany(SubTask::class);
|
|
}
|
|
|
|
public static function getUserIdFromBearerToken($token)
|
|
{
|
|
$token = PersonalAccessToken::findToken($token);
|
|
|
|
return $token->tokenable_id;
|
|
}
|
|
|
|
}
|