PHP code example of sopheak / sp-laravel-api

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

    

sopheak / sp-laravel-api example snippets




declare(strict_types=1);

use Sopheak\Core\Types\RecordBelongsToType;
use Sopheak\Core\Types\RecordHasManyType;
use Sopheak\Core\Types\RecordTableType;

return new RecordTableType(
    pmsName: 'order',
    table: 'orders',
    isAuthRead: true,
    isAuthWrite: true,
    canRead: true,
    canCreate: true,
    canUpdate: true,
    canDelete: true,
    canUpsert: true,
    relationships: [
        'customer' => new RecordBelongsToType(
            table: 'customers',
            foreignKey: 'customer_id',
            ownerKey: 'id',
        ),
        'items' => new RecordHasManyType(
            table: 'order_items',
            foreignKey: 'order_id',
            localKey: 'id',
        ),
    ],
);
bash
   php artisan sp-laravel-api:setup
   
bash
   php artisan migrate
   
bash
   php artisan sp-laravel-api:validate