chore: init saasshop repo + sql migrations runner + gitee go
This commit is contained in:
50
app/Models/Merchant.php
Normal file
50
app/Models/Merchant.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Merchant extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'merchants';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'slug', 'domain', 'contact_name', 'contact_phone', 'contact_email',
|
||||
'plan', 'status', 'trial_ends_at', 'activated_at', 'settings',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'trial_ends_at' => 'datetime',
|
||||
'activated_at' => 'datetime',
|
||||
'settings' => 'array',
|
||||
];
|
||||
|
||||
public function admins(): HasMany
|
||||
{
|
||||
return $this->hasMany(Admin::class, 'merchant_id');
|
||||
}
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class, 'merchant_id');
|
||||
}
|
||||
|
||||
public function products(): HasMany
|
||||
{
|
||||
return $this->hasMany(Product::class, 'merchant_id');
|
||||
}
|
||||
|
||||
public function orders(): HasMany
|
||||
{
|
||||
return $this->hasMany(Order::class, 'merchant_id');
|
||||
}
|
||||
|
||||
public function categories(): HasMany
|
||||
{
|
||||
return $this->hasMany(ProductCategory::class, 'merchant_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user