PHP code example of omerkoseoglu / devextreme-data-laravel

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

    

omerkoseoglu / devextreme-data-laravel example snippets


use DevExtreme\Data\Laravel\Facades\DevExtreme;

Route::get('/api/orders', fn () => DevExtreme::response(Order::class));

// any builder, relation or constraint
Route::get('/api/my-orders', fn (Request $r) =>
    DevExtreme::response($r->user()->orders()->where('status', 'open'))
);

use DevExtreme\Data\Laravel\EloquentSource;

$source = EloquentSource::for(
    Order::query()
        ->join('customers', 'customers.id', '=', 'orders.customer_id')
        ->select('orders.id', 'orders.total', 'customers.name as customer_name'),
    columns: ['id' => 'id', 'total' => 'total', 'customer.name' => 'customer_name'],
);

Route::get('/api/orders', fn () => DevExtreme::response($source));

$options = $request->devExtremeOptions(); // DevExtreme\Data\LoadOptions