chore: init saasshop repo + sql migrations runner + gitee go

This commit is contained in:
萝卜
2026-03-10 11:31:02 +00:00
commit 50f15cdea8
210 changed files with 29534 additions and 0 deletions

49
app/Models/Admin.php Normal file
View File

@@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Admin extends Model
{
use HasFactory;
protected $fillable = [
'merchant_id', 'name', 'email', 'phone', 'password', 'role', 'status', 'last_login_at',
];
protected $hidden = [
'password', 'remember_token',
];
protected $casts = [
'last_login_at' => 'datetime',
];
public function merchant(): BelongsTo
{
return $this->belongsTo(Merchant::class, 'merchant_id');
}
public function merchantId(): ?int
{
return $this->merchant_id ? (int) $this->merchant_id : null;
}
public function isPlatformAdmin(): bool
{
return $this->merchantId() === null;
}
public function isMerchantAdmin(): bool
{
return $this->merchantId() !== null;
}
public function platformLabel(): string
{
return $this->isPlatformAdmin() ? 'platform' : 'merchant';
}
}