Skip to content

Model alias support #2428

Answered by dutchman1990
dutchman1990 asked this question in Q&A
May 6, 2023 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

Sorry for the late response. Found another way to bind that with model. Which is written as secondary solution.

Solution 1
With enforceMorphMap
I had to write below code in AppServiceProvider.php 's boot method.

use Illuminate\Database\Eloquent\Relations\Relation; 

public function boot() {
        Relation::enforceMorphMap([
            'SubDealers' => 'App\Models\Partners\Subdealer\tbl_subdealer_master'
        ]);
    }

and below line in model file.

protected $guard_name = 'web'; //this could be a custom guard. I choose to go with default one.

Solution 2 - Secondary Solution
I had to append one model attribute name as id to bind roles object with the model. This one may have flaws. I…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@drbyte
Comment options

@drbyte
Comment options

@drbyte
Comment options

@dutchman1990
Comment options

Answer selected by drbyte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants