PHP code example of sweet1s / moonshine-database

1. Go to this page and download the library: Download sweet1s/moonshine-database library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sweet1s / moonshine-database example snippets


public function boot(): void
    {
        app(MoonShine::class)->menu([
            ...
            \Sweet1s\MoonShineDatabase\Menu\DatabaseItem::make(),
            ...
        ]);
    }

...
'auth' => [
    'enable' => true
],
...



namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;use Illuminate\Support\Facades\Gate;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        ...
        foreach (config('moonshine-database.auth.permissions') as $key => $value) {
            Gate::define($value, function ($user) use ($value) {
                // Here you can implement your own authorization logic

                // I use spatie/laravel-permission package, so I can do like this:
                return $user->role->hasPermissionTo($value);
            });
        }
    }
}

bash
php artisan vendor:publish --provider="Sweet1s\MoonShineDatabase\Providers\MoonShineDatabaseServiceProvider"