8000 [8.x] Replace direct application class mention by illuminate contract by alexmakii · Pull Request #36089 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[8.x] Replace direct application class mention by illuminate contract #36089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Illuminate/Database/Eloquent/Factories/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Closure;
use Faker\Generator;
use Illuminate\Container\Container;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Application;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\ForwardsCalls;< B5D2 /span>
Expand Down Expand Up @@ -635,7 +635,7 @@ public function modelName()
$resolver = static::$modelNameResolver ?: function (self $factory) {
$factoryBasename = Str::replaceLast('Factory', '', class_basename($factory));

$appNamespace = static::appNamespace();
$appNamespace = static::appNamespace(Container);

return class_exists($appNamespace.'Models\\'.$factoryBasename)
? $appNamespace.'Models\\'.$factoryBasename
Expand Down Expand Up @@ -710,7 +710,7 @@ protected function withFaker()
public static function resolveFactoryName(string $modelName)
{
$resolver = static::$factoryNameResolver ?: function (string $modelName) {
$appNamespace = static::appNamespace();
$appNamespace = static::appNamespace(Container);

$modelName = Str::startsWith($modelName, $appNamespace.'Models\\')
? Str::after($modelName, $appNamespace.'Models\\')
Expand All @@ -725,12 +725,13 @@ public static function resolveFactoryName(string $modelName)
/**
* Get the application namespace for the application.
*
* @param $container
* @return string
*/
protected static function appNamespace()
protected static function appNamespace($container)
{
try {
return Container::getInstance()
return $container::getInstance()
->make(Application::class)
->getNamespace();
} catch (Throwable $e) {
Expand Down
0