Open jangidgirish opened 1 year ago
This looks like not an issue to me, but rather expected behavior as you can't change query for Form's Model.
In Grid you can do it (as you probably did), but for the Form it takes Model and does findOrFail
with all booted scopes etc, so you not only can't edit values within the Grid, but open Edit form / page for the Instance that is not-active (in your example) / not-found.
The only OK solution for this I can suggest is to use not the original Model class, but extended and modified AdminModel class, that doesn't have said global scopes registered. For example:
<?php
namespace App\Admin\Models;
use App\Models\User as Model;
class User extends Model
{
protected static function booted()
{
// NOTE: empty for the override
}
}
And in your App\Admin\Controllers\UserController
use App\Admin\Models\User
instead of App\Models\User
.
And in your App\Admin\Controllers\UserController use App\Admin\Models\User instead of App\Models\User.
thanks for your suggestion, this can work, but I am planning to use global scope in 4-5 models which will be extended only for admin task. i was expecting when it's working in grid and view model then it should also work as same in form model.
Description:
The form model is not maintaining global scope methods in the quick update, i have called global scope disable method like
$form->model()->withoutGlobalScope('status')
but when i try to quick update status field from grid the code is throwing errorNo query results for model [App\Models\User] 16
Steps To Reproduce: