Skip to content

Commit

Permalink
Customer bank accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelnakamura committed Jul 31, 2024
1 parent 281a82e commit 5c2bd80
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/Models/Customer/BankAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Bildvitta\IssCrm\Models\Customer;

use Bildvitta\IssCrm\Models\Bank;
use Bildvitta\IssCrm\Scopes\Customer\RealEstateAgencyScope;
use Bildvitta\IssCrm\Traits\UsesCrmDB;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Ramsey\Uuid\Uuid;

class BankAccount extends Model
{
use UsesCrmDB;
use SoftDeletes;

protected $connection = 'iss-crm';

protected $table = 'customer_bank_accounts';

protected $guard_name = 'web';

public static function boot()
{
parent::boot();

self::creating(function ($model) {
$model->uuid = (string)Uuid::uuid4();
});
}

public function getRouteKeyName()
{
return 'uuid';
}

//

public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id', 'id')
->withoutGlobalScope(RealEstateAgencyScope::class);
}

public function bank()
{
return $this->belongsTo(Bank::class, 'bank_id', 'id');
}
}
5 changes: 5 additions & 0 deletions src/Models/Customer/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,9 @@ public function heritage_properties()
{
return $this->hasMany(HeritageProperty::class, 'customer_id', 'id');
}

public function bank_accounts()
{
return $this->hasMany(BankAccount::class, 'customer_id', 'id');
}
}

0 comments on commit 5c2bd80

Please sign in to comment.