laravel-crm icon indicating copy to clipboard operation
laravel-crm copied to clipboard

Unable to install Package

Open dharmikvyas opened this issue 2 years ago • 11 comments

  • Laravel CRM Version: 0.10.0 || 0.10.1
  • PHP Version: 7.4

Description:

I am unable to add this package to my existing project. When I execute following command composer require venturedrake/laravel-crm

Problem 1 - owen-it/laravel-auditing[v13.0.0, ..., 13.x-dev] require illuminate/console ^7.0|^8.0|^9.0 -> found illuminate/console[v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev] but these were not loaded, likely because it conflicts with another require. - venturedrake/laravel-crm 0.10.1 requires owen-it/laravel-auditing ^13.0 -> satisfiable by owen-it/laravel-auditing[v13.0.0, ..., 13.x-dev]. - Root composer.json requires venturedrake/laravel-crm ^0.10.1 -> satisfiable by venturedrake/laravel-crm[0.10.1].

You can also try re-running composer require with an explicit version constraint, e.g. "composer require venturedrake/laravel-crm:*" to figure out if any version is installable, or "composer require venturedrake/laravel-crm:^2.1" if you know which you need.

Steps To Reproduce:

dharmikvyas avatar Aug 31 '22 10:08 dharmikvyas

Looks like conflict with the laravel-auditing package I set up for audit logging. What version of Laravel are you using?

andrewdrake avatar Sep 02 '22 00:09 andrewdrake

I am using this project. https://github.com/hrshadhin/school-management-system. I think it's 6.

dharmikvyas avatar Sep 02 '22 04:09 dharmikvyas

I'll take a look, yes it's Laravel 6. Might be an issue with PHP 7.4, I'll do some testing

andrewdrake avatar Sep 02 '22 04:09 andrewdrake

I have just released some updates and with latest version managed to get the package to install via composer. Please note I haven't completed a full install on that school management system. It is a bit out of date itself, no released for 2 years. Try a full install yourself and let me know if it works ok. I am also working on a CLI installer for the CRM as it is a bit manual at the moment.

andrewdrake avatar Sep 03 '22 05:09 andrewdrake

Ok.

dharmikvyas avatar Sep 03 '22 05:09 dharmikvyas

I have gone through all the installation steps but while executing 6th migration step it gives me following error.


Migrating: 2022_09_03_182548_create_permission_tables

   Illuminate\Database\QueryException  : SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'permissions' already exists (SQL: create table `permissions` (`id` bigint unsigned not null auto_increment primary key, `name` varchar(255) not null, `guard_name` varchar(255) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8 collate 'utf8_unicode_ci')

  at /Applications/MAMP/htdocs/cloudschool1/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
    665|         // If an exception occurs when attempting to run a query, we'll format the error
    666|         // message to include the bindings with SQL, which will make this exception a
    667|         // lot more helpful to the developer instead of just the database's errors.
    668|         catch (Exception $e) {
  > 669|             throw new QueryException(
    670|                 $query, $this->prepareBindings($bindings), $e
    671|             );
    672|         }
    673| 

  Exception trace:

  1   PDOException::("SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'permissions' already exists")
      /Applications/MAMP/htdocs/cloudschool1/vendor/laravel/framework/src/Illuminate/Database/Connection.php:463

  2   PDOStatement::execute()
      /Applications/MAMP/htdocs/cloudschool1/vendor/laravel/framework/src/Illuminate/Database/Connection.php:463

  Please use the argument -v to see more details.

So I changed table name from database/XX_create_permission_tables.php to crm_permissions So I am getting this error

ErrorException  : Undefined index: crm_permissions

 at /Applications/MAMP/htdocs/cloudschool1/database/migrations/2022_09_03_182548_create_permission_tables.php:28
   24|         if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
   25|             throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
   26|         }
   27| 
 > 28|         Schema::create($tableNames['crm_permissions'], function (Blueprint $table) {
   29|             $table->bigIncrements('id');
   30|             $table->string('name');       // For MySQL 8.0 use string('name', 125);
   31|             $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
   32|             $table->timestamps();

 Exception trace:

 1   Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Undefined index: crm_permissions", "/Applications/MAMP/htdocs/cloudschool1/database/migrations/2022_09_03_182548_create_permission_tables.php", [])
     /Applications/MAMP/htdocs/cloudschool1/database/migrations/2022_09_03_182548_create_permission_tables.php:28

 2   CreatePermissionTables::up()
     /Applications/MAMP/htdocs/cloudschool1/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:392

 Please use the argument -v to see more details.

dharmikvyas avatar Sep 03 '22 15:09 dharmikvyas

Ah ok, this is an interesting use case. The school management project has permissions tables already, which will conflict with the Spatie permissions package I have implemented. There is a way around this. Let me make some updates and run a few tests.

andrewdrake avatar Sep 04 '22 08:09 andrewdrake

Hi, any update sir? I would like to use in my school management system (to give it a wing to fly) If I can do anything from my side to remove this error I would like to work on that please help.

dharmikvyas avatar Sep 09 '22 14:09 dharmikvyas

Can you try this:

  1. Add this to your env file

LARAVEL_CRM_PERMISSION_TABLE_PREFIX=crm_

  1. Replace the "permissions.php" file in the application config folder with this new version

https://github.com/venturedrake/laravel-crm/blob/master/config/permission.php

  1. Run the migrate command.

This should allow the Spatie package tables to use alternative table names so not as to conflict with the tables currently in the schools package.

andrewdrake avatar Sep 12 '22 01:09 andrewdrake

Hi, Sorry couldn't get permission.php file from provided URL. Can you please send me again? I am sorry for little late. :(

dharmikvyas avatar Sep 14 '22 08:09 dharmikvyas

Link should be https://github.com/venturedrake/laravel-crm/blob/master/config/permission.php

andrewdrake avatar Sep 14 '22 23:09 andrewdrake