PHP code example of zodexnl / spatie-permission-to-vue-inertia

1. Go to this page and download the library: Download zodexnl/spatie-permission-to-vue-inertia 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/ */

    

zodexnl / spatie-permission-to-vue-inertia example snippets


use SpatiePermissionsToVueInertia\Traits\SpatiePermissionsToVue;

class User extends Authenticatable
{
    use SpatiePermissionsToVue;
    
}

public function share(Request $request)
{
    return array_merge(parent::share($request), [
        'permissions' => json_decode(auth()->check() ? auth()->user()->jsPermissions() : '{}', true),
    ]);
}