Php 过滤和排序在数字和日期方面无法按预期工作
我在最新的Laravel 8上使用Laravel兰花。 我的供应商模型和迁移Php 过滤和排序在数字和日期方面无法按预期工作,php,laravel,admin,Php,Laravel,Admin,我在最新的Laravel 8上使用Laravel兰花。 我的供应商模型和迁移 Schema::create('vendors', function (Blueprint $table) { $table->id(); $table->string('display_name'); $table->string('contact_name'); $table->string('
Schema::create('vendors', function (Blueprint $table) {
$table->id();
$table->string('display_name');
$table->string('contact_name');
$table->string('email')->unique();
$table->string('url')->unique();
$table->string('password');
$table->string('contact');
$table->text('bio')->nullable();
$table->boolean('sponsored')->default(false);
$table->boolean('is_freelance')->default(false);
$table->boolean('is_commisioned')->default(false);
$table->boolean('auto_approve')->default(false);
$table->boolean('status')->default(true);
$table->timestamps();
});
protected $fillable = [
'display_name',
'contact_name',
'url',
'email',
'password',
'contact',
'bio',
'status',
'sponsored',
'is_freelance',
'is_commisioned',
'auto_approve'
];
protected $allowedFilters = [
'display_name',
'contact_name',
'url',
'email',
'contact',
'status',
'sponsored',
'is_freelance',
'is_commisioned',
'auto_approve',
'created_at',
'updated_at',
];
protected $allowedSorts = [
'display_name',
'contact_name',
'url',
'email',
'status',
'sponsored',
'is_freelance',
'is_commisioned',
'auto_approve',
'created_at',
'updated_at',
];
TD::make('email', 'Email')
->render(function (Vendor $vendor) {
return Link::make($vendor->email)
->route('platform.vendor.edit', $vendor);
})->filter(TD::FILTER_TEXT),
TD::make('url', 'Url')
->render(function (Vendor $vendor) {
return Link::make($vendor->url)
->route('platform.vendor.edit', $vendor);
})->filter(TD::FILTER_TEXT),
TD::make('display_name', 'Disp Name')->filter(TD::FILTER_TEXT),
TD::make('contact_name', 'Contact Name')->filter(TD::FILTER_TEXT)->sort(),
TD::make('contact', 'Contact')->filter(TD::FILTER_TEXT),
TD::make('status', 'Status')->filter(TD::FILTER_TEXT),
TD::make('created_at', 'Created')->filter(TD::FILTER_DATE)->sort(),
TD::make('updated_at', 'Last edit')->filter(TD::FILTER_DATE)->sort()
->render(function ($vendor) {
if ($vendor->updated_at) {
$date = $vendor->updated_at->toDayDateTimeString();
} else {
$date = 'n/a';
}
return $date;
}),
我的兰花布局为供应商
Schema::create('vendors', function (Blueprint $table) {
$table->id();
$table->string('display_name');
$table->string('contact_name');
$table->string('email')->unique();
$table->string('url')->unique();
$table->string('password');
$table->string('contact');
$table->text('bio')->nullable();
$table->boolean('sponsored')->default(false);
$table->boolean('is_freelance')->default(false);
$table->boolean('is_commisioned')->default(false);
$table->boolean('auto_approve')->default(false);
$table->boolean('status')->default(true);
$table->timestamps();
});
protected $fillable = [
'display_name',
'contact_name',
'url',
'email',
'password',
'contact',
'bio',
'status',
'sponsored',
'is_freelance',
'is_commisioned',
'auto_approve'
];
protected $allowedFilters = [
'display_name',
'contact_name',
'url',
'email',
'contact',
'status',
'sponsored',
'is_freelance',
'is_commisioned',
'auto_approve',
'created_at',
'updated_at',
];
protected $allowedSorts = [
'display_name',
'contact_name',
'url',
'email',
'status',
'sponsored',
'is_freelance',
'is_commisioned',
'auto_approve',
'created_at',
'updated_at',
];
TD::make('email', 'Email')
->render(function (Vendor $vendor) {
return Link::make($vendor->email)
->route('platform.vendor.edit', $vendor);
})->filter(TD::FILTER_TEXT),
TD::make('url', 'Url')
->render(function (Vendor $vendor) {
return Link::make($vendor->url)
->route('platform.vendor.edit', $vendor);
})->filter(TD::FILTER_TEXT),
TD::make('display_name', 'Disp Name')->filter(TD::FILTER_TEXT),
TD::make('contact_name', 'Contact Name')->filter(TD::FILTER_TEXT)->sort(),
TD::make('contact', 'Contact')->filter(TD::FILTER_TEXT),
TD::make('status', 'Status')->filter(TD::FILTER_TEXT),
TD::make('created_at', 'Created')->filter(TD::FILTER_DATE)->sort(),
TD::make('updated_at', 'Last edit')->filter(TD::FILTER_DATE)->sort()
->render(function ($vendor) {
if ($vendor->updated_at) {
$date = $vendor->updated_at->toDayDateTimeString();
} else {
$date = 'n/a';
}
return $date;
}),
问题1:对于联系人筛选器,我必须按完整的联系人号码进行搜索,它不像文本筛选器那样可以按任意数量的字符进行搜索。对于包含数字数据的其他字符串列也是如此
问题2:日期过滤器不工作。
谢谢你的帮助。非常感谢