PHP code example of bisual / laravel-shortcuts

1. Go to this page and download the library: Download bisual/laravel-shortcuts 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/ */

    

bisual / laravel-shortcuts example snippets


return [
];

public static $storeRequestClass = StorePostRequest::class;
public static $updateRequestClass = UpdatePostRequest::class;

namespace App\Mcp\Cruds;

use App\Models\CompanyProduct;
use App\Repositories\CompanyProductRepository;
use Bisual\LaravelShortcuts\Mcp\CrudMcpResource;
use Illuminate\Contracts\Auth\Authenticatable;

final class CompanyProductCrudMcp extends CrudMcpResource
{
    public static string $model = CompanyProduct::class;
    public static string $repository = CompanyProductRepository::class;

    public static ?array $only = ['index', 'show']; // which tools to register

    public static array $abilities = [
        'index' => 'index', // Policy uses index instead of viewAny
    ];

    public static function prepareIndexParams(array &$params, Authenticatable $user): void
    {
        // e.g. force a scope
    }
}

use App\Mcp\Cruds\CompanyProductCrudMcp;
use App\Mcp\Cruds\ProductTaskCrudMcp;
use Bisual\LaravelShortcuts\Mcp\CrudMcpResource;
use Laravel\Mcp\Server;

final class BisualServer extends Server
{
    protected function boot(): void
    {
        $this->tools = [
            ...CrudMcpResource::toolsFrom([
                CompanyProductCrudMcp::class,
                ProductTaskCrudMcp::class,
            ]),
        ];
    }
}

final class CompanyProductCrudMcp extends CrudMcpResource
{
    public static ?array $mcp_with = [
        'company',
        'company_product_phases',
        'company_product_phases..company_product_phase_boards',
        'company_product_phases..company_product_phase_boards..company_product_phase_board_cols',
    ];
    public static ?array $mcp_scopes = ['isActive'];
    public static ?array $mcp_filterable = ['id', 'title', 'code', 'company_id'];
    public static int $mcp_relation_depth = 1;
}

use Bisual\LaravelShortcuts\Mcp\AuthenticatedMcpTool;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
use Laravel\Mcp\Response;

final class CompanyChatSearchTool extends AuthenticatedMcpTool
{
    protected ?int $rateLimitMaxAttempts = 30;

    protected function rules(): array
    {
        return ['company_product_id' => '     return [
            'company_product_id' => $schema->integer()->
bash
php artisan vendor:publish --tag="laravel-shortcuts-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-shortcuts-config"
bash
php artisan vendor:publish --tag="laravel-shortcuts-views"
bash
php artisan make:repository Post
php artisan make:repository Post --model=Post
bash
php artisan make:dto RegisterUser
bash
php artisan make:request-dto RegisterUser
bash
php artisan make:mcp-crud-resource Post
php artisan make:mcp-crud-resource Post --model=Post --repository=PostRepository
bash
php artisan make:bisual-resource Post -crfspd
php artisan make:bisual-resource Post -cr --mcp
bash
?with=author&author.company_id=1