tabacitu on flash-alerts-to-session
tabacitu on master
flash warning alerts to session… Merge pull request #228 from La… (compare)
php artisan config:clear
This is my scope
public function scopeTeamDescendants($query, $user_id)
{
return $query->where('id', '=', $user_id)
->with('descendants')
->first()
->descendants;
}
This is my crudcrontoller
// This working ok (24 results)
dd(User::TeamDescendants(2020));
// This only get 1 result
CRUD::addClause('TeamDescendants', 2020);
// This return: CrudPanel::addScope does not exist.
$this->crud->addScope('TeamDescendants', 2020)
// This return: Method Illuminate\\Support\\Collection::getCountForPagination does not exist.
$this->crud->query = $this->crud->query->where('id', '=', $user_id)
->with('descendants')
->first()
->descendants;
I use this Laravel Eloquent extension: https://github.com/staudenmeir/laravel-adjacency-list for relathionships
$this->crud->addClause('teamDescendants, 2020);
Is correct, however, that teamDescendants
scope itself seems a bit off. Could you please create a question on stackoverflow.com including the code you show here, the related model classes, and an explanation of what exactly the teamDescendants
should do, then tag it with backpack-for-laravel
and post the link here? Im sure with that information we can help get you sorted :)
addClause
method calls return call_user_func_array([$this->query, $function], array_slice(func_get_args(), 1));
meaning you can use it to add any query method supported by laravel and whatever params you send with it will be forwarded correctly to that method, including whereBetween
and using closures and such
hi everyone, please a question. I'm using 'relationship' field and while records are appearing when I load the page, modifications aren't being saved (adding new records nor removing). I have the following on my CrudController:
protected function fetchUser()
{
// return $this->fetch(\App\Models\User::class);
return $this->fetch([
'name' => 'users',
'model' => \App\Models\User::class, // required
'searchable_attributes' => ['last_name', 'first_name', 'email'],
'paginate' => 10, // items to show per page
// 'query' => function($model) {
// return $model->active();
// } // to filter the results that
]);
and the relationship config:
[ // relationship
'type' => "relationship",
'name' => 'users', // the method on your model that defines the relationship
'ajax' => true,
// OPTIONALS:
'label' => "Category",
'attribute' => "email", // foreign key attribute that is shown to user (identifiable attribute)
'entity' => 'users', // the method that defines the relationship in your Model
'model' => "App\Models\User", // foreign key Eloquent model
'placeholder' => "Select users", // placeholder for the select2 input
// AJAX OPTIONALS:
'data_source' => url("client/fetch/user"), // url to controller search function (with /{id} should return model)
'minimum_input_length' => 2, // minimum characters to type before querying results
// 'dependencies' => [‘category’], // when a dependency changes, this select2 is reset to null
// 'include_all_form_fields' => false, // optional - only send the current field through AJAX (for a smaller payload if you're not using multiple chained select2s)
],
please any ideas what to check here? It's a 1-N relationship from client-> users, hope that's not causing issues.
Hi everyone, is it possible to add or modify the search function? I'm trying to search an exact value to an encrypted table on the database. But it seems it doesn't work. I wanted to add this to the search function but I'm not sure how to implement it.
$items = User::all()->filter(function($record) use($searchValue) {
if((decrypt($record->SSN) == $searchValue) {
return $record;
}
});
search
method to your CRUD controller as explained here or if you want to add logic for specific columns you can use the search attribute logic feature