Client request builder to laravel-crud-wizard
To be used for calling laravel-crud-wizard
See also free version laravel-crud-wizard-client-free
$crud = new \MacroPaySolutions\LaravelCrudWizardClient\RequestBuilder(\env('API_BEARER'), \env('APP_URL'));
try {
$result = $crud->list('clients', $crud->getBuilder()->sort('country', 'asc') // or $crud->bulkDelete(...
->sort('zip')->startsWith('name', 'alt')->isNull('lead')->withRelation('relation')
->withRelations(['rel1', 'rel2'])->addRelationFilter(
$crud->getRelationsBuilder('relation')->startsWith('relation_column', 'ex')
))->withSums(['summableColumn1', 'summableColumn2'])->addSubtotal('state', 'active')->addGroupBy('state')
->addCountRelations(['relation1'])->addHavings(['relation1_count' => 2]);
$result = $crud->listRelationByResource( // or $crud->bulkDeleteRelationByResource(...
'groups',
'1',
'clients',
$crud->getBuilder()->sort('zip', 'asc')->isNull('lead')->withRelation('relation')
->withRelations(['rel1', 'rel2'])
->withSums(['clientsSummableColumn1', 'clientsSummableColumn2'])
->addRelationFilter(
$crud->getRelationsBuilder('relationsRelation')->startsWith('relations_relation_column', 'ex')
)->addSubtotals(['state'], ['active'])->addGroupBys(['state'])
->addCountRelations(['groups'])->addHavings(['groups_count' => 2]);
);
$result = $crud->get('clients', '73', ['rel1', 'rel2']);
$result = $crud->delete('clients', '73');
$result = $crud->create('clients', [
'active' => '1',
'name' => 'abc',
// ...
]);
$result = $crud->update('clients', '73', [
'active' => '1',
'name' => 'abc',
// ...
]);
} catch (\Exception $e) {
$decodedErrorMessage = \json_decode($e->getMessage());
echo $decodedErrorMessage->message;
}
$decodedResult = \json_decode($result);
More methods are available after instal.