Hesto/multi-auth

Laravel 6 support

Opened this issue · 23 comments

Laravel 6 support

its not working with laravel 6.0

a Few amendments helped me work out php artisan commands, not sure if that will help. use Illuminate\Support\Str; and change str_<> to Str::<>, Str:snake. I am still testing if that works.

almost all the Traits has this bug for laravel 6.01 release. see if this helps....

Regards
Manish

getServiceInput())); } /** * Get the name of the lucid service passed as argument. * * @return string */ protected function getServiceInput() { return trim($this->argument('service')); } }
replaceNames($content); return $content; } /** * Get info message output * * @param $filePath * @return mixed */ protected function getInfoMessage($filePath) { return $this->info('Content changed in: ' . $filePath); } /** * Get the desired class name from the input. * * @return string */ protected function getParsedNameInput() { return mb_strtolower(Str::singular($this->getNameInput())); } /** * Get the desired class name from the input. * * @return string */ protected function getNameInput() { return trim($this->argument('name')); } /** * Get the console command arguments. * * @return array */ public function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the class'], ]; } /** * Check if stub's content exists in given file (path) * * @param $path * @param $stub * @return bool */ public function contentExists($path, $stub) { $originalContent = $this->files->get($path); $content = $this->replaceNames($this->files->get($stub)); if (Str::contains(trim($originalContent), trim($content))) { return true; } return false; } }
option('lucid') && !$this->getParsedServiceInput()) { $this->error('You must pass a Service name with the `--lucid` option.'); return true; } if ($this->option('force')) { $name = $this->getParsedNameInput(); $domain = $this->option('domain'); $lucid = $this->option('lucid'); $service = $this->getParsedServiceInput() ?: null; Artisan::call('multi-auth:settings', [ 'name' => $name, 'service' => $service, '--domain' => $domain, '--lucid' => $lucid, '--force' => true ]); Artisan::call('multi-auth:files', [ 'name' => $name, 'service' => $service, '--domain' => $domain, '--lucid' => $lucid, '--force' => true ]); if (!$this->option('model')) { Artisan::call('multi-auth:model', [ 'name' => $name, '--lucid' => $lucid, '--force' => true ]); $this->installMigration(); $this->installPasswordResetMigration(); } if (!$this->option('views')) { Artisan::call('multi-auth:views', [ 'name' => $name, 'service' => $service, '--lucid' => $lucid, '--force' => true ]); } if (!$this->option('routes')) { $this->installWebRoutes(); } $this->info('Multi Auth with ' . ucfirst($name) . ' guard successfully installed.'); return true; } $this->info('Use `-f` flag first.'); return true; } /** * Install Web Routes. * * @return bool */ public function installWebRoutes() { $lucid = $this->option('lucid'); $domain = $this->option('domain'); $service = $this->getParsedServiceInput(); if ($lucid) { $stub = !$domain ? __DIR__ . '/../stubs/Lucid/routes/web.stub' : __DIR__ . '/../stubs/Lucid/domain-routes/web.stub'; $lucidPath = base_path() . '/src/Services/' . studly_case($service) . '/Http/routes.php'; $lucidStub = !$domain ? __DIR__ . '/../stubs/Lucid/routes/map-method.stub' : __DIR__ . '/../stubs/Lucid/domain-routes/map-method.stub'; if (!$this->contentExists($lucidPath, $lucidStub)) { $lucidFile = new SplFileInfo($lucidStub); $this->appendFile($lucidPath, $lucidFile); } if (!$this->contentExists($lucidPath, $stub)) { $file = new SplFileInfo($stub); $this->appendFile($lucidPath, $file); return true; } return false; } $path = base_path() . '/routes/web.php'; $stub = __DIR__ . '/../stubs/routes/web.stub'; if ($domain) { $stub = __DIR__ . '/../stubs/domain-routes/web.stub'; } if (!$this->contentExists($path, $stub)) { $file = new SplFileInfo($stub); $this->appendFile($path, $file); return true; } return false; } /** * Install Migration. * * @return bool */ public function installMigration() { $name = $this->getParsedNameInput(); $migrationDir = base_path() . '/database/migrations/'; $migrationName = 'create_' . Str::plural(STR::snake($name)) . '_table.php'; $migrationStub = new SplFileInfo(__DIR__ . '/../stubs/Model/migration.stub'); $files = $this->files->allFiles($migrationDir); foreach ($files as $file) { if (Str::contains($file->getFilename(), $migrationName)) { $this->putFile($file->getPathname(), $migrationStub); return true; } } $path = $migrationDir . date('Y_m_d_His') . '_' . $migrationName; $this->putFile($path, $migrationStub); return true; } /** * Install PasswordResetMigration. * * @return bool */ public function installPasswordResetMigration() { $name = $this->getParsedNameInput(); $migrationDir = base_path() . '/database/migrations/'; $migrationName = 'create_' . STR::singular(STR::snake($name)) . '_password_resets_table.php'; $migrationStub = new SplFileInfo(__DIR__ . '/../stubs/Model/PasswordResetMigration.stub'); $files = $this->files->allFiles($migrationDir); foreach ($files as $file) { if (STR::contains($file->getFilename(), $migrationName)) { $this->putFile($file->getPathname(), $migrationStub); return true; } } $path = $migrationDir . date('Y_m_d_His', strtotime('+1 second')) . '_' . $migrationName; $this->putFile($path, $migrationStub); return true; } /** * Get the console command options. * * @return array */ public function getOptions() { return [ ['force', 'f', InputOption::VALUE_NONE, 'Force override existing files'], ['domain', false, InputOption::VALUE_NONE, 'Install in a subdomain'], ['lucid', false, InputOption::VALUE_NONE, 'Lucid architecture'], ['model', null, InputOption::VALUE_NONE, 'Exclude model and migration'], ['views', null, InputOption::VALUE_NONE, 'Exclude views'], ['routes', null, InputOption::VALUE_NONE, 'Exclude routes'], ]; } }
getSettings(); foreach ($settings as $setting) { $path = $setting['path']; $fullPath = base_path() . $path; if ($this->putContent($fullPath, $this->compileContent($fullPath, $setting))) { $this->getInfoMessage($fullPath); } } return true; } /** * Compile content. * * @param $path * @param $setting * @return mixed */ protected function compileContent($path, $setting) //It should be compile method instead { $originalContent = $this->files->get($path); $content = $this->replaceNames($this->files->get($setting['stub'])); if (!Str::contains(trim($originalContent), trim($content))) { if ($setting['prefix']) { $stub = $content . $setting['search']; } else { $stub = $setting['search'] . $content; } $originalContent = str_replace($setting['search'], $stub, $originalContent); } return $originalContent; } }
getNameInput())); } /** * Get the desired class name from the input. * * @return string */ protected function getNameInput() { return trim($this->argument('name')); } /** * Replace names with pattern. * * @param $template * @return $this */ public function replaceNames($template) { $name = $this->getParsedNameInput(); $service = $this->getParsedServiceInput(); $name = str::plural($name); $plural = [ '{{pluralCamel}}', '{{pluralSlug}}', '{{pluralSnake}}', '{{pluralClass}}', ]; $singular = [ '{{singularCamel}}', '{{singularSlug}}', '{{singularSnake}}', '{{singularClass}}', '{{singularServiceCamel}}', '{{singularServiceSlug}}', '{{singularServiceSnake}}', '{{singularServiceClass}}', ]; $replacePlural = [ Str::camel($name), Str::slug($name), Str::snake($name), ucfirst(Str::camel($name)), ]; $replaceSingular = [ Str::singular(Str::camel($name)), Str::singular(Str::slug($name)), Str::singular(Str::snake($name)), Str::singular(ucfirst(Str::camel($name))), Str::camel($service), Str::slug($service), Str::snake($service), ucfirst(Str::camel($service)), ]; $template = str_replace($plural, $replacePlural, $template); $template = str_replace($singular, $replaceSingular, $template); $template = str_replace('{{Class}}', ucfirst(Str::camel($name)), $template); return $template; } }
  1. ) Create a new Helper Directory inside app folder and create a helpers.php file and put all this function
    https://github.com/ajay-ag/blog/commit/e32425323e1722fc01158c0e09925b80cb010cfd
    Note : only string relented function

2.) put this code in service provider

foreach (glob(app_path().'/Helpers/*.php') as $filename){
require_once($filename);
}

For string related issues: run composer require laravel/helpers.
https://laravel.com/docs/6.x/upgrade#helpers

The current package isn't compatible with laravel 6.
I've replaced all the string functions by Str Helper.

You may check my repo: alaminfirdows/laravel-multi-auth

The current package isn't compatible with laravel 6.
I've replaced all the string functions by Str Helper.

You may check my repo: alaminfirdows/multi-auth

How to use the package with ur modifications?

Updated...

You may like this package, works on Laravel 6.*
alaminfirdows/laravel-multi-auth


I didn't create any package yet.
Just download/clone my repo and paste it on your vendor folder.

i did not change in package file , i have create separate file put the necessary functions

I didn't create any package yet.
Just download/clone my repo and paste it on your vendor folder.

Hello. Hesto/multi-auth can't be downloaded with Laravel 6.

  1. How can I download it on Laravel 6?
  2. How can I download ur modifications?
    Regards

Hello. Hesto/multi-auth can't be downloaded with Laravel 6.

  1. How can I download it on Laravel 6?
  2. How can I download ur modifications?
    Regards

Updated...

You may like this package, works on Laravel 6.*
alaminfirdows/laravel-multi-auth


Step 1: Install Through Composer
composer require hesto/multi-auth

Step 2: Download my modification from alaminfirdows/multi-auth

Step 3: Go to vendor folder of your project and past the files.

Thanks.

I think you can try this
All str_ and array_ helpers have been moved to the new laravel/helpers Composer package and removed from the framework. If desired, you may update all calls to these helpers to use the Illuminate\Support\Str and Illuminate\Support\Arr classes. Alternatively, you can add the new laravel/helpers package to your application to continue using these helpers:
composer require laravel/helpers

Then install hesto

I think you can try this
All str_ and array_ helpers have been moved to the new laravel/helpers Composer package and removed from the framework. If desired, you may update all calls to these helpers to use the Illuminate\Support\Str and Illuminate\Support\Arr classes. Alternatively, you can add the new laravel/helpers package to your application to continue using these helpers:
composer require laravel/helpers

Then install hesto

I'll try it if the previous way didnt work. Thanks

Hello. Hesto/multi-auth can't be downloaded with Laravel 6.

  1. How can I download it on Laravel 6?
  2. How can I download ur modifications?
    Regards

Step 1: Install Through Composer
composer require hesto/multi-auth

Step 2: Download my modification from alaminfirdows/multi-auth

Step 3: Go to vendor folder of your project and past the files.

Thanks.

hesto-files

Copy files to which folder? plz
Is there a direct way to send u some details with u, email for example?
Regards

Updated...

Dear all,
You may like this package, works on Laravel 6.*
alaminfirdows/laravel-multi-auth

The actual problem was string functions not exist on Laravel 6, I replaced it by Str Helper.
On my package, customized folders, and namespaces also.

This is no fix for this particular package.

But I have a similar multi-auth package that supports Laravel versions 5.3 to 6.x

https://github.com/mtvbrianking/multi-auth

image

You might wanna try it.