49 lines
1009 B
PHP
Executable File
49 lines
1009 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\Blameable;
|
|
use Altek\Accountant\Contracts\Recordable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
// use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class MemberPlan extends Model
|
|
{
|
|
use HasFactory, Blameable;
|
|
|
|
protected $fillable = [
|
|
'member_id',
|
|
'plan_id',
|
|
'status',
|
|
'start',
|
|
'end',
|
|
'created_by',
|
|
'updated_by',
|
|
'deleted_by',
|
|
];
|
|
|
|
public function member()
|
|
{
|
|
return $this->belongsTo(Member::class, 'member_id', 'member_id');
|
|
}
|
|
|
|
public function corporatePlan()
|
|
{
|
|
return $this->belongsTo(CorporatePlan::class, 'plan_id', 'code');
|
|
}
|
|
|
|
public function plan()
|
|
{
|
|
return $this->belongsTo(Plan::class, 'plan_id');
|
|
}
|
|
|
|
public function scopeActive($q)
|
|
{
|
|
return $q
|
|
->where('start', '<', now())
|
|
->where('end', '>', now())
|
|
->latest();
|
|
}
|
|
}
|