How to update CoreUI laravel admin template from laravel-7 to laravel-8

Update composer.json
1.1
Update require and require-dev:

"require": {
    "php": "^7.2.5",
    "fideloper/proxy": "^4.2",
    "laravel/framework": "^8.0",
    "fruitcake/laravel-cors": "^1.0",
    "guzzlehttp/guzzle": "^7.0.1",
    "laravel/tinker": "^2.3.0",
    "spatie/laravel-medialibrary": "^8.7.2",
    "spatie/laravel-permission": "^3.17",
    "laravel/ui": "^3.0"
},
"require-dev": {
    "facade/ignition": "^2.3.6",
    "fzaninotto/faker": "^1.9.1",
    "mockery/mockery": "^1.3.1",
    "nunomaduro/collision": "^5.0",
    "phpunit/phpunit": "^9.0"
},

1.2
Update autoload:

"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Database\\Factories\\": "database/factories/",
        "Database\\Seeders\\": "database/seeders/"
    },
    "classmap": [
        "database",
        "database/seeders",
        "database/factories"
    ],
    "files": [

    ]
},

Change folder name database/seeds to database/seeders
3.
Remove vendor folder, and composer.lock
Then run: composer install
4.
Edit seeders
4.1
In database Seeder change:

    $this->call('UsersAndNotesSeeder');
    $this->call('MenusTableSeeder');
    $this->call('FolderTableSeeder');
    $this->call('ExampleSeeder');
    $this->call('BREADSeeder');
    $this->call('EmailSeeder');

to this:

    $this->call([
        UsersAndNotesSeeder::class,
        MenusTableSeeder::class,
        FolderTableSeeder::class,
        ExampleSeeder::class,
        BREADSeeder::class,
        EmailSeeder::class,
    ]);

4.2
To every seeder add namespace namespace Database\Seeders;
5
Edit Factories
5.1
Change UserFactory.php content to this:

<?php namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; use App\Models\User as User; class UserFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = User::class; /** * Define the model's default state. * * @return array */ public function definition() { return [ 'name' => $this->faker->name, 'email' => $this->faker->unique()->safeEmail, 'email_verified_at' => now(), 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 'remember_token' => Str::random(10), 'menuroles' => 'user' ]; } public function admin() { return $this->state(function (array $attributes) { return [ 'menuroles' => 'user,admin', ]; }); } }

5.2
Change content of StatusFactory.php to this:

<?php namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; use App\Models\Status as Status; class StatusFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Status::class; /** * Define the model's default state. * * @return array */ public function definition() { return [ 'name' => $this->faker->word, 'class' => $this->faker->word ]; }

5.3 Change content of NotesFactory.php to this:

<?php namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; use App\Models\Notes; use App\Models\User as User; use App\Models\Status; class NotesFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Notes::class; /** * Define the model's default state. * * @return array */ public function definition() { return [ 'title' => $this->faker->sentence(4,true), 'content' => $this->faker->paragraph(3,true), 'status_id' => Status::factory()->create()->id, 'note_type' => $this->faker->word(), 'applies_to_date' => $this->faker->date(), 'users_id' => User::factory()->create()->id ]; } }

6
Use bootstrap pagination - in file app/Providers/AppServiceProvider.php
add line use Illuminate\Pagination\Paginator;
and to function boot() add line Paginator::useBootstrap();
7
In app/Models/Folder.php change lines:
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
to
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
And change line:
use HasMediaTrait;
to:
use InteractsWithMedia;
8
In database/migrations/2020_01_08_184500_create_media_table.php add to function create lines:
$table->string(‘conversions_disk’);
$table->unsignedBigInteger(‘uuid’);
9
Move User model
9.1
Move file app\User.php to app\Models folder.
9.2
In file app\Models\User.php change namespace to namespace App\Models;
9.3
Search the project for phrase: use App\User and replace it to use App\Models\User
9.4
In app\Models\Notes.php change line:
return $this->belongsTo(‘App\User’, ‘users_id’)->withTrashed();
to:
return $this->belongsTo(‘App\Models\User’, ‘users_id’)->withTrashed();
9.5
In config\auth.php change line number 71:
‘model’ => App\User::class,
to this:
‘model’ => App\Models\User::class,
10.
There are differences in unit tests for such a modified project.
The easiest solution is to take a new version of tests from the new version of our project.
If you need edit your tests here are some steps how to do it.
10.1
Change the way the factory are use. For example this:
$user = factory(‘App\User’)->create();
change to:
$user = User::factory()->create();
And this:
$user = factory(‘App\User’)->states(‘admin’)->create();
change to:
User::factory()->admin()->create();
10.2
Change the way the Role is assigned to user:
Role::create([‘name’ => ‘admin’]);
$user->assignRole(‘admin’);
Change to:
$adminRole = Role::create([‘name’ => ‘admin’]);
$user->assignRole($adminRole);
10.3
Don’t forget to add use App\Models\User; to tests.
11
To models App\Models\User, App\Models\Status, App\Models\Notes add line: use Illuminate\Database\Eloquent\Factories\HasFactory; and add line: use HasFactory; to model class.