admin quick edit
parent
927cdb0b29
commit
f070d69f74
|
|
@ -40,7 +40,9 @@ class KeywordController extends AdminController
|
|||
amis()->TableColumn()->name('id')->label(__('keywords.id')),
|
||||
amis()->TableColumn()->name('name')->label(__('keywords.name')),
|
||||
amis()->TableColumn()->name('key')->label(__('keywords.key')),
|
||||
amis()->TableColumn()->name('value')->label(__('keywords.value')),
|
||||
amis()->TableColumn()->name('value')->label(__('keywords.value'))->quickEdit([
|
||||
// 'saveImmediately' => true,
|
||||
]),
|
||||
$this->rowActions([
|
||||
$this->rowShowButton()->visible($user->can('keywords.show')),
|
||||
$this->rowEditButton()->visible($user->can('keywords.edit')),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModelFillable extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'model:fillable {table} {--connection}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'get model fillable ';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$table = $this->argument('table');
|
||||
$ignore = ['id', 'created_at', 'updated_at', 'deleted_at'];
|
||||
$connection = $this->option('connection');
|
||||
if (! $connection) {
|
||||
$connection = config('database.default');
|
||||
}
|
||||
|
||||
if (Schema::connection($connection)->hasTable($table)) {
|
||||
$list = Schema::connection($connection)->getColumnListing($table);
|
||||
$list = array_filter($list, function ($value) use ($ignore) {
|
||||
return ! in_array($value, $ignore);
|
||||
});
|
||||
$this->info("protected \$fillable = ['".implode('\', \'', $list)."'];");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,8 @@ class Keyword extends Model
|
|||
{
|
||||
use DatetimeFormatterTrait, Filterable, TreePath;
|
||||
|
||||
// protected $guarded = [];
|
||||
|
||||
protected $fillable = ['id', 'name', 'key', 'value', 'parent_id', 'path', 'sort', 'options', 'image', 'images', 'description', 'content'];
|
||||
|
||||
protected $casts = [
|
||||
|
|
|
|||
|
|
@ -88,6 +88,6 @@ class QueryLogServiceProvider extends ServiceProvider
|
|||
*/
|
||||
protected function writeLog($message, array $context = [])
|
||||
{
|
||||
Log::debug($message, $context);
|
||||
Log::channel('sql')->debug($message, $context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,15 @@ class KeywordService extends AdminService
|
|||
}
|
||||
}
|
||||
|
||||
public function query()
|
||||
public function sortable($query)
|
||||
{
|
||||
return $this->modelName::query()->sort();
|
||||
if (request()->orderBy && request()->orderDir) {
|
||||
$query->orderBy(request()->orderBy, request()->orderDir ?? 'asc');
|
||||
} else {
|
||||
$query->orderByDesc($this->sortColumn());
|
||||
}
|
||||
|
||||
$query->sort();
|
||||
}
|
||||
|
||||
public function deleted($ids)
|
||||
|
|
|
|||
|
|
@ -16,23 +16,16 @@ trait TreePath
|
|||
{
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Model $model) {
|
||||
if ($model->parent_id) {
|
||||
$parent = static::query()->findOrFail($model->parent_id);
|
||||
$model->path = $parent->path . $parent->id . '-';
|
||||
} else {
|
||||
$model->parent_id = 0;
|
||||
$model->path = '-';
|
||||
}
|
||||
});
|
||||
|
||||
static::updating(function (Model $model) {
|
||||
if ($model->parent_id) {
|
||||
$parent = static::query()->findOrFail($model->parent_id);
|
||||
$model->path = $parent->path . $parent->id . '-';
|
||||
} else {
|
||||
$model->parent_id = 0;
|
||||
$model->path = '-';
|
||||
static::saving(function (Model $model) {
|
||||
if ($model->isDirty('parent_id')) {
|
||||
$pid = $model->parent_id;
|
||||
if ($pid) {
|
||||
$parent = static::query()->findOrFail($pid);
|
||||
$model->path = $parent->path . $parent->id . '-';
|
||||
} else {
|
||||
$model->parent_id = 0;
|
||||
$model->path = '-';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,13 @@ return [
|
|||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'sql' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/sql.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use Illuminate\Database\Seeder;
|
|||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Slowlyo\OwlAdmin\Models\{AdminMenu, AdminPermission};
|
||||
use Slowlyo\OwlAdmin\Support\Cores\Database;
|
||||
|
||||
class AdminPermissionSeeder extends Seeder
|
||||
{
|
||||
|
|
@ -16,7 +15,6 @@ class AdminPermissionSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Database::make()->fillInitialData();
|
||||
DB::table('admin_menus')->truncate();
|
||||
DB::table('admin_permissions')->truncate();
|
||||
DB::table('admin_permission_menu')->truncate();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
namespace Tests\Feature;
|
||||
|
||||
// use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
use App\Models\Keyword;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
|
|
@ -12,11 +14,7 @@ class ExampleTest extends TestCase
|
|||
*/
|
||||
public function test_the_application_returns_a_successful_response(): void
|
||||
{
|
||||
$arr = ['a' => 1, 'b' => 2];
|
||||
$b = [
|
||||
...$arr,
|
||||
'a' => 'A'
|
||||
];
|
||||
dump($b);
|
||||
$keyword = Keyword::findOrFail(20);
|
||||
dump($keyword->parent_ids);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue