Update Linking With ASO
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -23,7 +24,7 @@ class Corporate extends Model
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'linking_rules' => 'array',
|
||||
'linking_rules' => AsArrayObject::class,
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
|
||||
@@ -141,7 +141,8 @@ class Member extends Model
|
||||
|
||||
public function currentPlan()
|
||||
{
|
||||
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id')->latest();
|
||||
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id')
|
||||
->latest(); // TODO Fix This
|
||||
}
|
||||
|
||||
public function policies()
|
||||
|
||||
@@ -31,4 +31,17 @@ class MemberPlan extends Model
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user