chore: init saasshop repo + sql migrations runner + gitee go
This commit is contained in:
53
app/Models/User.php
Normal file
53
app/Models/User.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
protected $fillable = [
|
||||
'merchant_id', 'name', 'email', 'phone', 'password', 'status',
|
||||
'register_source', 'last_login_source', 'wechat_openid', 'wechat_unionid', 'mini_openid',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function merchant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Merchant::class, 'merchant_id');
|
||||
}
|
||||
|
||||
public function orders(): HasMany
|
||||
{
|
||||
return $this->hasMany(Order::class);
|
||||
}
|
||||
|
||||
public function oauthAccounts(): HasMany
|
||||
{
|
||||
return $this->hasMany(OauthAccount::class);
|
||||
}
|
||||
|
||||
public function scopeForMerchant(Builder $query, int $merchantId): Builder
|
||||
{
|
||||
return $query->where('merchant_id', $merchantId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user