35 lines
719 B
PHP
35 lines
719 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
|
||
|
|
class CoinExchange extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = [];
|
||
|
|
protected $guarded = [];
|
||
|
|
|
||
|
|
public function user()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(User::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function scopeKeyword($query)
|
||
|
|
{
|
||
|
|
$keyword = request()->keyword;
|
||
|
|
return $query->whereHas('user', function ($sql) use($keyword) {
|
||
|
|
$sql->where('nickname', 'like', '%'.$keyword.'%');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public function scopeStatus($query)
|
||
|
|
{
|
||
|
|
return $query->where('status', request()->status);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function goods()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(ExchangeGoods::class, 'goods_id', 'id');
|
||
|
|
}
|
||
|
|
}
|