initial: bootstrap from BukidBountyApp base

This commit is contained in:
Jonathan Sykes
2026-06-06 18:43:00 +08:00
commit eb4a5731fb
5674 changed files with 160857 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class Cart extends Model
{
protected ?string $table = 'carts';
protected array $fillable = [
'hashkey',
'user_id',
'is_active',
'created_by',
'updated_by',
];
protected array $casts = [
'is_active' => 'boolean',
];
public function items()
{
return $this->hasMany(CartItem::class, 'cart_id');
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
}

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
class CartItem extends Model
{
protected ?string $table = 'cart_items';
protected array $fillable = [
'hashkey',
'cart_id',
'product_id',
'quantity',
'price',
'is_active',
'created_by',
'updated_by',
];
protected array $casts = [
'is_active' => 'boolean',
'quantity' => 'integer',
'price' => 'float',
];
public function cart()
{
return $this->belongsTo(Cart::class, 'cart_id');
}
public function product()
{
return $this->belongsTo(Product::class, 'product_id');
}
}

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\User;
use Hypervel\Database\Eloquent\Model;
class CooperativeDocument extends Model
{
protected ?string $table = 'cooperative_documents';
protected array $fillable = [
'hashkey',
'parent_hashkey',
'version_number',
'organization_id',
'file_hashkey',
'document_type',
'revision_note',
'created_by',
'updated_by',
'is_active',
];
public function organization()
{
return $this->belongsTo(Organization::class, 'organization_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class CooperativeMember extends Model
{
protected ?string $table = 'cooperative_members';
protected array $fillable = [
'hashkey', 'organization_id', 'user_id', 'role',
'membership_type', 'membership_level',
'officer_position', 'officer_level',
'concurrent_position', 'concurrent_level',
'cooperative_name_alt', 'cooperative_position', 'year_beginning',
// Classification
'priority_sector', 'common_bond', 'vulnerability_classifications',
// Government IDs
'philsys_id', 'sss_number', 'pagibig_number',
// SLP
'slp_track', 'slp_association_name', 'listahanan_id', 'fourtps_household_id',
// TUPAD
'tupad_category', 'tupad_insurance_beneficiary_name', 'tupad_insurance_beneficiary_relation',
// OSEC/NSRP
'preferred_occupation', 'nsrp_skills', 'employment_status',
// Programs
'program_participation',
'joined_at', 'is_active', 'created_by', 'updated_by',
];
protected array $casts = [
'joined_at' => 'datetime',
'is_active' => 'boolean',
'priority_sector' => 'array',
'vulnerability_classifications' => 'array',
'nsrp_skills' => 'array',
'program_participation' => 'array',
];
public function organization()
{
return $this->belongsTo(Organization::class, 'organization_id');
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class CooperativeResolution extends Model
{
protected ?string $table = 'cooperative_resolutions';
protected array $fillable = [
'hashkey',
'organization_id',
'title',
'description',
'date_approved',
'document_url',
'status',
'created_by',
'updated_by',
'is_active',
];
protected array $casts = [
'date_approved' => 'date',
'is_active' => 'boolean',
];
public function organization()
{
return $this->belongsTo(Organization::class, 'organization_id');
}
public function votes()
{
return $this->hasMany(CooperativeVote::class, 'resolution_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class CooperativeVote extends Model
{
protected ?string $table = 'cooperative_votes';
protected array $fillable = [
'hashkey',
'resolution_id',
'user_id',
'vote_cast',
'created_by',
'updated_by',
'is_active',
];
protected array $casts = [
'is_active' => 'boolean',
];
public function resolution()
{
return $this->belongsTo(CooperativeResolution::class, 'resolution_id');
}
public function voter()
{
return $this->belongsTo(User::class, 'user_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class Courier extends Model
{
protected ?string $table = 'couriers';
protected array $fillable = [
'hashkey',
'name',
'contact_number',
'type',
'is_active',
'created_by',
'updated_by',
];
protected array $casts = [
'is_active' => 'boolean',
];
public function shipments()
{
return $this->hasMany(Shipment::class, 'courier_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class Customer extends Model
{
protected ?string $table = 'cst';
protected array $fillable = [
'hashkey',
'name',
'phone',
'email',
'store_id',
'user_id',
'created_by',
'updated_by',
'is_active',
];
protected array $casts = [
'is_active' => 'boolean',
];
/**
* Relationships
*/
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
}

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class FarmerProfile extends Model
{
protected ?string $table = 'farmer_profiles';
protected array $fillable = [
'hashkey',
'user_id',
'organization_id',
'farm_name',
'farm_location',
'main_crops',
'verification_status',
'certification_details',
'is_active',
'created_by',
'updated_by',
];
protected array $casts = [
'main_crops' => 'array',
'certification_details' => 'array',
'is_active' => 'boolean',
];
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function organization()
{
return $this->belongsTo(Organization::class, 'organization_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class MainOrganization extends Model
{
protected ?string $table = 'main_organizations';
protected array $fillable = [
'organization_id',
'role',
'priority',
'is_active',
'metadata',
'created_by',
'updated_by',
];
protected array $casts = [
'is_active' => 'boolean',
'priority' => 'integer',
'metadata' => 'array',
];
public function organization()
{
return $this->belongsTo(Organization::class, 'organization_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class Organization extends Model
{
protected ?string $table = 'organizations';
protected array $fillable = [
'hashkey',
'name',
'type',
'address',
'registration_number',
'cin',
'tin',
'cooperative_type',
'cooperative_category',
'registration_date',
'contact_person',
'contact_number',
'contact_email',
'compliance_status',
'is_active',
'created_by',
'updated_by',
];
protected array $casts = [
'is_active' => 'boolean',
'registration_date' => 'date',
];
public function members()
{
return $this->hasMany(CooperativeMember::class, 'organization_id');
}
public function farmerProfiles()
{
return $this->hasMany(FarmerProfile::class, 'organization_id');
}
public function stores()
{
return $this->belongsToMany(Store::class, 'org_str', 'organization_id', 'store_id')
->withTimestamps();
}
public function mainAssignments()
{
return $this->hasMany(MainOrganization::class, 'organization_id');
}
public function isMain(?string $role = null): bool
{
$query = $this->mainAssignments()->where('is_active', true);
if ($role !== null) {
$query->where('role', $role);
}
return $query->exists();
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
/**
* @property int $id
* @property string $hashkey
* @property string $access_key
* @property int $store_id
* @property string $name
* @property string $status
* @property string $last_used_at
* @property int $created_by
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*/
class PosAccessKey extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'pos_access_keys';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [
'hashkey',
'access_key',
'store_id',
'name',
'status',
'is_active',
'expires_at',
'last_used_at',
'created_by',
'updated_by',
];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = [
'id' => 'integer',
'store_id' => 'integer',
'created_by' => 'integer',
'updated_by' => 'integer',
'is_active' => 'boolean',
'expires_at' => 'datetime',
];
/**
* Check if this access key is expired.
*/
public function isExpired(): bool
{
return $this->expires_at !== null && $this->expires_at->isPast();
}
/**
* Auto-expire: set all expired active keys to inactive.
* Call this before listing or validating keys.
*/
public static function autoExpire(): void
{
self::where('status', 'active')
->whereNotNull('expires_at')
->where('expires_at', '<', now())
->update(['status' => 'inactive']);
}
/**
* Relationships
*/
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
}

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class PosSession extends Model
{
protected ?string $table = 'pos_sessions';
protected array $fillable = [
'hashkey',
'access_key',
'store_id',
'created_by',
'updated_by',
'customer_name',
'total_amount',
'received_amount',
'change_amount',
'payment_method',
'payment_details',
'status',
'is_void',
'notes',
'additionaldata',
];
protected array $casts = [
'is_void' => 'boolean',
'payment_details' => 'array',
'additionaldata' => 'array',
'total_amount' => 'integer',
'received_amount' => 'integer',
'change_amount' => 'integer',
'created_by' => 'integer',
'updated_by' => 'integer',
];
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
/**
* Relationships
*/
public function transactions()
{
return $this->hasMany(PosTransaction::class, 'pos_session_id');
}
public function archives()
{
return $this->hasMany(PosSessionArchive::class, 'pos_session_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class PosSessionArchive extends Model
{
protected ?string $table = 'pos_sessions_archive';
protected array $fillable = [
'pos_session_id',
'hashkey',
'session_snapshot',
'transactions_snapshot',
'created_by',
'updated_by',
'remarks',
];
protected array $casts = [
'session_snapshot' => 'array',
'transactions_snapshot' => 'array',
'created_by' => 'integer',
'updated_by' => 'integer',
'pos_session_id' => 'integer',
];
/**
* Relationships
*/
public function session()
{
return $this->belongsTo(PosSession::class, 'pos_session_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
class PosTransaction extends Model
{
protected ?string $table = 'pos_transactions';
protected array $fillable = [
'pos_session_id',
'product_id',
'quantity',
'price_at_sale',
'discount',
'total_price',
'is_void',
'remarks',
'hashkey',
'created_by',
'updated_by',
];
protected array $casts = [
'is_void' => 'boolean',
'quantity' => 'integer',
'price_at_sale' => 'integer',
'discount' => 'integer',
'total_price' => 'integer',
'created_by' => 'integer',
'updated_by' => 'integer',
];
/**
* Relationships
*/
public function session()
{
return $this->belongsTo(PosSession::class, 'pos_session_id');
}
public function product()
{
return $this->belongsTo(Product::class, 'product_id');
}
}

View File

@@ -0,0 +1,91 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class Product extends Model
{
protected ?string $table = 'prd_items';
protected string $primaryKey = 'id';
public bool $incrementing = true;
protected string $keyType = 'int';
protected array $fillable = [
'hashkey',
'created_by',
'updated_by',
'created_for',
'category',
'subcategory',
'logs',
'specs',
'photourl',
'available',
'sold',
'price',
// 'store_id',
'owner_id',
'views',
'name',
'description',
'reviews',
'barcode',
'status',
'remarks',
'unitname',
'rating',
'sku',
'qrcode',
'shortcode',
'shortname',
'is_active',
'product_type'
];
protected array $casts = [
'available' => 'integer',
'sold' => 'integer',
'price' => 'integer',
'views' => 'integer',
'rating' => 'integer',
'is_active' => 'boolean',
'photourl' => 'array',
'reviews' => 'array',
'specs' => 'array',
];
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
public function stores()
{
return $this->belongsToMany(Store::class, 'prd_str')
->withPivot(['available', 'price', 'is_active'])
->withTimestamps();
}
public function owner()
{
return $this->belongsTo(User::class, 'owner_id');
}
public function createdFor()
{
return $this->belongsTo(User::class, 'created_for');
}
}

View File

@@ -0,0 +1,102 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class ProductTransaction extends Model
{
protected ?string $table = 'prd_trx';
/**
* The primary key for the model.
*/
protected string $primaryKey = 'id';
/**
* Indicates if the IDs are auto-incrementing.
*/
public bool $incrementing = true;
/**
* The "type" of the primary key.
*/
protected string $keyType = 'int';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [
'hashkey',
'created_by',
'updated_by',
'created_for',
'store_id',
'transactiontype',
'product_id',
'transactiondata',
'description',
'subtype',
'name',
'owner_id',
'transactionsessionhash',
'quantity',
'logs',
'remarks',
'price',
'is_void',
'last_total_price',
'last_total_discount',
'notes'
];
/**
* The attributes that should be cast.
*/
protected array $casts = [
'quantity' => 'integer',
'price' => 'integer',
'is_void' => 'boolean',
];
/**
* Relationships.
*/
public function product()
{
return $this->belongsTo(Product::class, 'product_id');
}
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
public function owner()
{
return $this->belongsTo(User::class, 'owner_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
public function createdFor()
{
return $this->belongsTo(User::class, 'created_for');
}
public function session()
{
return $this->belongsTo(ProductTransactionSession::class, 'transactionsessionhash', 'hashkey');
}
}

View File

@@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class ProductTransactionSession extends Model
{
protected ?string $table = 'prd_trx_ses';
/**
* The primary key for the model.
*/
protected $primaryKey = 'id';
/**
* Indicates if the IDs are auto-incrementing.
*/
public $incrementing = true;
/**
* The "type" of the primary key.
*/
protected $keyType = 'int';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [
'hashkey',
'name',
'description',
'logs',
'remarks',
'created_by',
'updated_by',
'created_for',
'subtype',
'additionaldata',
'category',
'store_id',
'status',
'is_void',
'last_total_price',
'last_total_discount',
'notes',
];
protected array $casts = [
'is_void' => 'boolean',
];
/**
* Relationships.
*/
public function transactions()
{
return $this->hasMany(ProductTransaction::class, 'transactionsessionhash', 'hashkey');
}
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
public function createdFor()
{
return $this->belongsTo(User::class, 'created_for');
}
}

View File

@@ -0,0 +1,72 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class ProductTransactionSessionArchive extends Model
{
protected ?string $table = 'prd_trx_ses_arc';
/**
* The primary key for the model.
*/
protected $primaryKey = 'id';
/**
* Indicates if the IDs are auto-incrementing.
*/
public $incrementing = true;
/**
* The "type" of the primary key.
*/
protected $keyType = 'int';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [
'name',
'description',
'details',
'hashkey',
'transactions_sessions_id',
'created_by',
'updated_by',
'created_for',
'transactions_snapshot'
];
protected array $casts = [
'details' => 'array',
'transactions_snapshot' => 'array',
];
/**
* Relationships.
*/
public function transactionSession()
{
return $this->belongsTo(ProductTransactionSession::class, 'transactions_sessions_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
public function createdFor()
{
return $this->belongsTo(User::class, 'created_for');
}
}

View File

@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
use App\Models\GlobalTransaction;
class Shipment extends Model
{
protected ?string $table = 'shipments';
protected array $fillable = [
'hashkey',
'transaction_id',
'store_id',
'customer_id',
'courier_id',
'tracking_number',
'status',
'origin_address',
'destination_address',
'estimated_delivery_date',
'actual_delivery_date',
'shipping_fee',
'is_active',
'created_by',
'updated_by',
];
protected array $casts = [
'estimated_delivery_date' => 'datetime',
'actual_delivery_date' => 'datetime',
'shipping_fee' => 'decimal:2',
'is_active' => 'boolean',
];
public function transaction()
{
return $this->belongsTo(GlobalTransaction::class, 'transaction_id');
}
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id');
}
public function courier()
{
return $this->belongsTo(Courier::class, 'courier_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

117
app/Models/Market/Store.php Normal file
View File

@@ -0,0 +1,117 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class Store extends Model
{
protected ?string $table = 'str';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [
'hashkey',
'storecode',
'name',
'description',
'status',
'created_by',
'updated_by',
'created_for',
'remarks',
'logs',
'specs',
'additionaldata',
'owner_id',
'manager_id',
'category',
'subcategory',
'photourl',
'address',
'is_active',
'store_type',
];
protected array $casts = [
'photourl' => 'array',
'is_active' => 'boolean',
'store_type'=> 'array',
'specs' => 'array',
];
/**
* Relationships
*/
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
public function createdFor()
{
return $this->belongsTo(User::class, 'created_for');
}
public function owner()
{
return $this->belongsTo(User::class, 'owner_id');
}
public function manager()
{
return $this->belongsTo(User::class, 'manager_id');
}
public function managers()
{
return $this->hasMany(StoreManager::class, 'store_id');
}
public function managerUsers()
{
return $this->belongsToMany(User::class, 'store_managers', 'store_id', 'user_id')
->withPivot(['hashkey', 'created_by', 'updated_by', 'is_active'])
->withTimestamps();
}
// public function products()
// {
// return $this->hasMany(Product::class, 'store_id');
// }
public function products()
{
return $this->belongsToMany(Product::class, 'prd_str')
->withPivot(['available', 'price', 'is_active','sold','logs','reviews','status','remarks','description'])
->withTimestamps();
}
public function cooperatives()
{
return $this->belongsToMany(Organization::class, 'org_str', 'store_id', 'organization_id')
->where('organizations.type', 'COOPERATIVE')
->withTimestamps();
}
public function transactions()
{
return $this->hasMany(ProductTransaction::class, 'store_id');
}
public function transactionSessions()
{
return $this->hasMany(ProductTransactionSession::class, 'store_id');
}
}

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class StoreManager extends Model
{
protected ?string $table = 'store_managers';
protected array $fillable = [
'hashkey',
'store_id',
'user_id',
'created_by',
'updated_by',
'is_active',
];
protected array $casts = [
'is_active' => 'boolean',
];
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}

View File

@@ -0,0 +1,114 @@
<?php
declare(strict_types=1);
namespace App\Models\Market;
use App\Models\Model;
use App\Models\User;
class UserInfo extends Model
{
protected ?string $table = 'user_infos';
protected array $fillable = [
'hashkey',
'user_id',
'firstname',
'middlename',
'lastname',
'suffix',
'gender',
'dob',
'priority_sector',
'messenger_id',
'viber_number',
'tiktok_username',
'region',
'province',
'city',
'barangay',
'civil_status',
'children_count',
'dependent_count',
'education_level',
'course',
'school',
'year_last_attended',
'livelihood_source',
'last_company',
'employer_name',
'last_position',
'occupation',
'last_employment_year',
'monthly_income',
'tin',
'philhealth_id',
'gov_id',
'id_type',
'id_number',
'beneficiary_type',
'emergency_contact_name',
'emergency_contact_address',
'emergency_contact_phone',
'emergency_contact_relation',
'emergency_contact_user_id',
'fullname',
'landline',
'mobile',
'email',
'alt_email',
'alt_landline',
'alt_mobile',
'facebook_url',
'bank_details',
'bank_account_no',
'addresses',
'other_details',
'is_active',
'created_by',
'updated_by',
];
protected array $casts = [
'bank_details' => 'json',
'addresses' => 'json',
'other_details' => 'json',
'is_active' => 'boolean',
'dob' => 'date',
'monthly_income' => 'float',
'children_count' => 'integer',
'dependent_count' => 'integer',
];
/**
* Get the virtual age attribute.
*/
public function getAgeAttribute(): ?int
{
if (!$this->dob) {
return null;
}
return $this->dob->diffInYears(now());
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function emergencyContactUser()
{
return $this->belongsTo(User::class, 'emergency_contact_user_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}