This repository has been archived on 2026-09-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2026-01-14 00:54:08 +00:00

61 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class ParentProfile extends Model
{
use SoftDeletes;
protected $fillable = [
'user_id',
'phone',
'address_line1',
'address_line2',
'town',
'postcode',
'country',
'notes',
];
/**
* Link back to the user account for this parent.
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Optional: link to billing accounts where this parent is primary.
*/
public function billingAccounts()
{
return $this->hasMany(BillingAccount::class, 'primary_parent_user_id', 'user_id');
}
public function students(): BelongsToMany
{
return $this->belongsToMany(
StudentProfile::class,
'parent_student',
'parent_profile_id', // this model's FK on the pivot
'student_profile_id' // related model's FK on the pivot
)
->withPivot('relationship', 'notes')
->withTimestamps();
}
public function parentProfile(): HasOne
{
return $this->hasOne(ParentProfile::class);
}
}