38 lines
886 B
PHP
38 lines
886 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class LuckyWheelTicket extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = ['customer_id','invoice_id','max_times'];
|
|
|
|
public function luckyWheel()
|
|
{
|
|
return $this->belongsTo(LuckyWheel::class);
|
|
}
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function prize()
|
|
{
|
|
return $this->hasOne(LuckyWheelPrize::class,"ticket_id")->with('voucher');
|
|
}
|
|
|
|
public function gets()
|
|
{
|
|
return $this->hasMany(LuckyWheelGet::class,"ticket_id")->with("prize","voucher")->orderBy("created_at","desc");
|
|
}
|
|
|
|
public function get()
|
|
{
|
|
return $this->hasOne(LuckyWheelGet::class,"ticket_id")->whereNotNull("redeem_at")->with("voucher","prize");
|
|
}
|
|
} |