Monday, March 19, 2018

Laravel morphedByMany Query Returns NULL - development

Laravel morphedByMany Query Returns NULL

I have this model

class Permission extends Model
{

      public function details(): MorphToMany
    {
        return $this->morphedByMany('AppModelsDetails', 'model', 'model_has_permissions', 'permission_id', 'model_id');

    }
}

class Details extends Model
{

   public function permission()
    {

    return $this->morphedByMany('AppModelsPermission','model','model_has_permissions','model_id','permission_id');
    }
}

I’m execute this query

Details::with('permission')->find(55);

and got empty array

why happen this?and what is the correct query?



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-morphedbymany-query-returns-null/
via Lzo Media

No comments:

Post a Comment