mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
update: return number of order when login.
This commit is contained in:
@@ -55,13 +55,15 @@ class GeneratesAuthenticationToken {
|
||||
|
||||
/** @var Company $companyModule */
|
||||
$companyModule = $user->companyModule()->first();
|
||||
$order = $companyModule->orders->count();
|
||||
|
||||
$claims = [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'type' => $user->type,
|
||||
'status' => $user->status
|
||||
'status' => $user->status,
|
||||
'order' => $order
|
||||
];
|
||||
|
||||
if($user->type === RoleTypes::USER) {
|
||||
|
||||
@@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
@@ -56,6 +58,15 @@ class CompanyModule extends AbstractModel
|
||||
return $this->belongsToMany(User::class, (new CompanyEmployee())->getTable(), 'company_module_id', 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function orders(): HasMany
|
||||
{
|
||||
return $this->HasMany(Order::class, 'company_module_id');
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * @return HasMany
|
||||
// */
|
||||
|
||||
Reference in New Issue
Block a user