Crud: Limit data

Created on 4 Dec 2016  路  3Comments  路  Source: Laravel-Backpack/CRUD

Hi
Is there anyway to determine that specific data load from table instead of all data in the admin panel ?

Most helpful comment

Ah okay, yes I think I understand.

You can use the addClause functionality or filters.

Clauses look like

// ------ ADVANCED QUERIES
$this->crud->addClause('active');
$this->crud->addClause('type', 'car');
$this->crud->addClause('where', 'name', '==', 'car');
$this->crud->addClause('whereName', 'car');
$this->crud->addClause('whereHas', 'posts', function($query) {
     $query->activePosts();
 });
$this->crud->orderBy();
$this->crud->groupBy();
$this->crud->limit();

and filters are documented here -> https://laravel-backpack.readme.io/docs/filters

Hopefuly that should give what you're after, I'll close the thread now to keep the place tidy, feel free to reply

All 3 comments

Sorry don't quite understand? Could you maybe give an example of what's wrong please?

By default this package load all data from a table in database. I want to limit it . for example we have a Book Model . I want just show the books with specific category in table view, not all books ? Is it clear ?

Ah okay, yes I think I understand.

You can use the addClause functionality or filters.

Clauses look like

// ------ ADVANCED QUERIES
$this->crud->addClause('active');
$this->crud->addClause('type', 'car');
$this->crud->addClause('where', 'name', '==', 'car');
$this->crud->addClause('whereName', 'car');
$this->crud->addClause('whereHas', 'posts', function($query) {
     $query->activePosts();
 });
$this->crud->orderBy();
$this->crud->groupBy();
$this->crud->limit();

and filters are documented here -> https://laravel-backpack.readme.io/docs/filters

Hopefuly that should give what you're after, I'll close the thread now to keep the place tidy, feel free to reply

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexgmin picture alexgmin  路  3Comments

bahman2216 picture bahman2216  路  3Comments

mikael1000 picture mikael1000  路  3Comments

AlexanderWM picture AlexanderWM  路  3Comments

sokvebolkol picture sokvebolkol  路  3Comments