Aplikasi Keuangan yang mengatur lalu lintas transaksi antara bank dan aplikasi internal Kampus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

51 lines
1.8 KiB

<?php
namespace App\Domains\Channel\Providers;
use App\Domains\Channel\Models\Client;
use App\Domains\Finance\Models\Invoice;
use App\Domains\Finance\Models\ProductMapping;
use Illuminate\Support\ServiceProvider;
class RelationshipServiceProvider extends ServiceProvider
{
/**
* Boot cross-domain runtime relationships.
*
* This provider is strictly dedicated to runtime, decoupled cross-domain
* relationship definitions. Use Model::resolveRelationUsing() here to wire
* explicit polymorphic or foreign-key macros between models that live in
* different domains — without introducing a hard compile-time dependency
* between those domains.
*
* Do NOT add route registrations, bindings, event listeners, or any other
* bootstrapping logic here. Keep this file focused on relationships only.
*
* Example:
*
* Order::resolveRelationUsing('customer', fn (Order $order) =>
* $order->belongsTo(Customer::class, 'customer_id')
* );
*/
public function boot(): void
{
// Register cross-domain relationships below.
Client::resolveRelationUsing('transaction', fn (Client $client) => $client->hasMany(
related: Invoice::class,
foreignKey: 'client_id'
));
Invoice::resolveRelationUsing('client', fn (Invoice $transaction) => $transaction->belongsTo(
related: Client::class,
foreignKey: 'client_id'
));
Client::resolveRelationUsing('product_mapping', fn (Client $client) => $client->hasMany(
related: ProductMapping::class,
foreignKey: 'client_id'
));
ProductMapping::resolveRelationUsing('client', fn (ProductMapping $productMapping) => $productMapping->belongsTo(
related: Client::class,
foreignKey: 'client_id'
));
}
}