orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.26k stars 631 forks source link

Adding a field to role model #2647

Closed AlizHarb closed 12 months ago

AlizHarb commented 1 year ago

How is possible to rewrite on the role model? i would like to add extra fillable columns

czernika commented 1 year ago
  1. Create new migration file to add new column(s)
  2. Create new Role model which extends default Orchid one
namespace App\Models;

use Orchid\Platform\Models\Role as OrchidRole;

class Role extends OrchidRole
{
    // change $fillable
}
  1. Replace Orchid\Platform\Models\Role with App\Models\Role everywhere in your app
  2. Add Role class mapping within any ServiceProvider class - this will ensure roles relationship returns exact your model
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use App\Models\Role;
use Orchid\Platform\Models\Role as OrchidRole;
use Orchid\Support\Facades\Dashboard;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Dashboard::useModel(OrchidRole::class, Role::class);
    }
}