Skip to content

Commit

Permalink
Update: Lumen installation migration workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ekmungai committed Apr 28, 2021
1 parent 0f60b7e commit 1328dc1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,37 @@ composer require "ekmungai/eloquent-ifrs"
composer install --no-dev
```

If using Lumen, make sure to register the package with your application by adding the `IFRSServiceProvider` to the `app.php` in the bootstrap folder.

```php
<?php

use IFRS\IFRSServiceProvider;

require_once __DIR__.'/../vendor/autoload.php';
...

/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/

// $app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
$app->register(IFRSServiceProvider::class);
...
}
...
?>
```

Then run migrations to create the database tables.

```php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ function (Blueprint $table) {

private function getTableName()
{
$userModel = is_array(config('ifrs.user_model')) ? config('ifrs.user_model')[intval(App::version())] : config('ifrs.user_model');
$versionString = App::version();
$version = strpos($versionString, "Components") > 0 ? substr($versionString, 7, 1) : $versionString;
$userModel = is_array(config('ifrs.user_model')) ? config('ifrs.user_model')[intval($version)] : config('ifrs.user_model');
return (new $userModel())->getTable();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Schema;

class CreateIfrsRecycledObjectsTable extends Migration
Expand All @@ -29,7 +30,9 @@ function (Blueprint $table) {
$table->unsignedBigInteger('user_id');

// constraints
$userModel = is_array(config('ifrs.user_model')) ? config('ifrs.user_model')[intval(App::version())] : config('ifrs.user_model');
$versionString = App::version();
$version = strpos($versionString, "Components") > 0 ? substr($versionString, 7, 1) : $versionString;
$userModel = is_array(config('ifrs.user_model')) ? config('ifrs.user_model')[intval($version)] : config('ifrs.user_model');
$table->foreign('entity_id')->references('id')->on(config('ifrs.table_prefix').'entities');
$table->foreign('user_id')->references('id')->on((new $userModel())->getTable());

Expand Down
2 changes: 1 addition & 1 deletion src/IFRSServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function register()
public function boot()
{
$this->publishes([
__DIR__ . '/../config/ifrs.php' => config_path('ifrs.php'),
__DIR__ . '/../config/ifrs.php' => app()->configPath('ifrs.php'),
]);

$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
Expand Down

0 comments on commit 1328dc1

Please sign in to comment.