lundi 3 septembre 2018

Get class name of models in collection even if there are no instances in laravel

Assume I have the following eloquent queries:

$collection_one = User::all();
$collection_two = Post::all();

When there are users in the collection, I can do the following in order to get the class name of the models in the collection:

$class_name = class_basename($collection_one->first());

However, I cannot figure out how to get the class name for Post, say, when there are no posts in the system.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire