Answers for "les request possible de laravel eloquent"

PHP
0

laravel list of models

<?php
// found link from https://stackoverflow.com/questions/34053585/how-do-i-get-a-list-of-all-models-in-laravel
// and then finally found on https://gist.github.com/mohammad425/231242958edb640601108bdea7bcf9ac
function getAllModels(): array
{
        $composer = json_decode(file_get_contents(base_path('composer.json')), true);
        $models = [];
        foreach ((array)data_get($composer, 'autoload.psr-4') as $namespace => $path) {
            $models = array_merge(collect(File::allFiles(base_path($path)))
                ->map(function ($item) use ($namespace) {
                    $path = $item->getRelativePathName();
                    return sprintf('\%s%s',
                        $namespace,
                        strtr(substr($path, 0, strrpos($path, '.')), '/', '\\'));
                })
                ->filter(function ($class) {
                    $valid = false;
                    if (class_exists($class)) {
                        $reflection = new \ReflectionClass($class);
                        $valid = $reflection->isSubclassOf(\Illuminate\Database\Eloquent\Model::class) &&
                            !$reflection->isAbstract();
                    }
                    return $valid;
                })
                ->values()
                ->toArray(), $models);
        }
        return $models;
}
Posted by: Guest on October-29-2020
0

how to see with page reuested in laravel

$request->fullUrl()
Posted by: Guest on November-07-2020

Code answers related to "les request possible de laravel eloquent"

Browse Popular Code Answers by Language