I have model include of several relation for example like this:
public function NewsCategory()
{
return $this->belongsTo("News\Model\NewsCategory");
}
public function NewsImage()
{
return $this->belongsTo("News\Model\NewsImage");
}
public function NewsTag()
{
return $this->belongsTo("News\Model\NewsTag");
}
and relations create dynamically.
How can I get all this class name? In this example I wantNewsCategory,NewsImage,NewsTag
one approach is to as follows :
$results = ModelClass::where(x,y)->with(['NewsCategory','NewsImage','NewsTag'])->first();
then you can use getRelations();
$relationshipKeys = array_keys($results->getRelations());
$model_specific_method_name_array = array_diff(get_class_methods(<YourMOdel>), get_class_methods(<AnotherDummyEloquentModelWithoutAnyMethods>));
Then remove other known methods on your model from array.