List of functions that works for Laravel Eloquent models.
This is the list of functions that you can import and use on your Laravel app through the static methods of the OpenSoutheners\ExtendedLaravel\Helpers class.
modelFrom
Gets model fully qualified class or instanced object from given string.
Helpers::modelFrom('post');// 'App\Models\Post'Helpers::modelFrom('post',false);// object instance for App\Models\PostHelpers::modelFrom('post',true,'Domain\Posts');// 'Domain\Posts\Post'
Creates a model instance from given key (generally its ID or specified primary key).
Helpers::instanceFrom(1,App\Models\Post::class);// object instance for App\Models\Post with ID 1Helpers::instanceFrom(1,App\Models\Post::class, ['id','title']);// object instance for App\Models\Post with ID 1 and only selecting id and title columnsHelpers::instanceFrom(1,App\Models\Post::class, ['*'], ['author']);// object instance for App\Models\Post with ID 1 and with author relationship loaded
keyFrom
Tries to get Eloquent model key from given variable (can be of multiple types).
Gets always a new Eloquent query builder instance from given model.
Helpers::queryFrom(App\Models\Post::class);// object instance for \Illuminate\Database\Eloquent\BuilderHelpers::queryFrom(App\Models\Post::query()->where('title','hello'));// new object instance for \Illuminate\Database\Eloquent\Builder
getCacheLockOwner
Get cache atomic locks owner or false otherwise if no lock found.