PHP code example of forest-lynx / moonshine-resource-lock

1. Go to this page and download the library: Download forest-lynx/moonshine-resource-lock 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/ */

    

forest-lynx / moonshine-resource-lock example snippets



//...
use ForestLynx\MoonShine\Traits\WithResourceLock;

class PostResource extends ModelResource
{
    use WithResourceLock;
//...



namespace App\Actions;

use ForestLynx\ResourceLock\Actions\ResourceLockOwnerAction;

class CustomActions extends ResourceLockOwnerAction
{
    public function execute(Model|Authenticatable $user): ?string
    {
        return $user->email;
    }
}

    //...
    -'resource_lock_owner' => \ForestLynx\MoonShine\Actions\ResourceLockOwnerAction::class
    +'resource_lock_owner' => \App\Actions\CustomActions::class
    //...


//...
class PostResource extends ModelResource
{
    //...
    use WithResourceLock;
    //...
    protected function getReturnUrlResourceLock(): string
    {
        return 'https://...';
    }
    //...
}


//...
class PostResource extends ModelResource
{
    //...
    use WithResourceLock;
    //...
    public function isDisplayOnIndexPage(): bool
    {
        return false;
    }
    //...
}
bash
php artisan resource-lock:install
bash
php artisan resource-lock:clear-old
bash
php artisan vendor:publish --tag=resource-lock-config
bash
php artisan vendor:publish --tag=resource-lock-lang