spatie / laravel-multitenancy

Make your Laravel app usable by multiple tenants
https://spatie.be/docs/laravel-multitenancy
MIT License
1.08k stars 154 forks source link

Package v2.1.0 seems broken. Migrations not working... #238

Closed BartMommens closed 3 years ago

BartMommens commented 3 years ago

After installing the v2.1.0 package and configuring it migration will not work:

PHP Fatal error:  Cannot declare class CreateLandlordTenantsTable, because the name is already in use in /Projects/testing/laravel/mt-fortify-sanct-rp/mt-f-s-rp-v1/database/migrations/landlord/create_landlord_tenants_table.php on line 7

   Symfony\Component\ErrorHandler\Error\FatalError 

  Cannot declare class CreateLandlordTenantsTable, because the name is already in use

  at database/migrations/landlord/create_landlord_tenants_table.php:7
      3▕ use Illuminate\Database\Migrations\Migration;
      4▕ use Illuminate\Database\Schema\Blueprint;
      5▕ use Illuminate\Support\Facades\Schema;
      6▕ 
  ➜   7▕ class CreateLandlordTenantsTable extends Migration
      8▕ {
      9▕     public function up()
     10▕     {
     11▕         Schema::create('tenants', function (Blueprint $table) {

   Whoops\Exception\ErrorException 

  Cannot declare class CreateLandlordTenantsTable, because the name is already in use

  at database/migrations/landlord/create_landlord_tenants_table.php:7
      3▕ use Illuminate\Database\Migrations\Migration;
      4▕ use Illuminate\Database\Schema\Blueprint;
      5▕ use Illuminate\Support\Facades\Schema;
      6▕ 
  ➜   7▕ class CreateLandlordTenantsTable extends Migration
      8▕ {
      9▕     public function up()
     10▕     {
     11▕         Schema::create('tenants', function (Blueprint $table) {

      +1 vendor frames 
  2   [internal]:0
      Whoops\Run::handleShutdown()
BartMommens commented 3 years ago

Oke i figured out how to fix this.

The migration folder 'landlord' that is being generates in 2.1.0 has date_time infront of it unlike 1.8, and the file inside does not

2.0: folder: 2021_05_06_141413_landlord file: create_landlord_tenants_table.php

1.8: folder: landlord file: 2021_05_06_143909_create_landlord_tenants_table.php

Getting the naming convention correctly in the publishing functionality will fix the issue.

Hope this will help for fixing the issue. I don't have any experience in fixing packages sorry else i would help :/

Best regards, Bart

masterix21 commented 3 years ago

Hi guys, thanks to all for the issue, but it isn't related to this package.

I have created a PR here (https://github.com/spatie/laravel-package-tools/pull/30) to fix the bug.

Thanks

BartMommens commented 3 years ago

Thanks for your work, dedication and launching the PR <3