mercredi 23 novembre 2016

Laravel Nayjest datagrid Stored procedure mapping

I'm new to Laravel 5 and i'm planning to use Nayjest datagrid for showing MySql dynamic stored procedure results.

Here is MySql stored procedure sample code:

CREATE DEFINER=`Dummy`@`%` PROCEDURE `get_contacts`(
  orderColumns VARCHAR(21844) CHARACTER SET utf8, 
  whereColumns VARCHAR(21844) CHARACTER SET utf8,
  likeColumns VARCHAR(21844) CHARACTER SET utf8
)
BEGIN
   ...
   PREPARE stmt FROM @sql_txt;
   EXECUTE stmt;
   DEALLOCATE PREPARE stmt;
END

Here is Laravel code

$cfg = [
        //'src' => DB::select('CALL get_contacts(null, null, null);')//'App\Models\Clients',
        'columns' => [
            'idClients',
            'Nom',
            'Prenom',
            'Adresse'
        ]
    ];
    $grid = Grids::make($cfg);
    $query = DB::select('CALL get_contacts(null, null, null);');
    $grid = $grid->setDataProvider($query);

In final version, columns name will be generated in the flow.

Seems it works only with EloquantServiceProvider

Any help?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire