我在我的webapplication中使用Select2.我用Ajax加载我的Select2框.验证失败时,除Select2框外,所有输入都按照之前的方式填充.如何在表单验证失败后恢复旧值?我的赌注是使用Request::old('x'),但这会插入值(在我的情况下是用户ID)而不是所选文本.因此,例如文本John将变为27选择框.我怎样才能收回文字?
<select id="customer" name="customer" class="searchselect searchselectstyle">
</select>
Run Code Online (Sandbox Code Playgroud)
js:
token = '{{csrf_token()}}';
$(".searchselect").select2({
ajax: {
dataType: "json",
type: "POST",
data: function (params) {
return {
term: params.term,
'_token': token,
'data' : function(){
var result = [];
var i = 1;
$('.searchselect').each(function(){
result[i] = $(this).val();
i++;
});
return result;
}
};
},
url: function() {
var type = $(this).attr('id');
return '/get' + type;
},
cache: false,
processResults: function (data) {
return {
results: data
};
} …Run Code Online (Sandbox Code Playgroud) 我需要知道如何验证 Laravel 中的变量。到现在为止,我只用$request这种方式进行验证。
$request->validate([
'idgroup' => [
'required',
'numeric',
new AdminGroupRequest,
new MaxInvitationAdmin
]
]);
Run Code Online (Sandbox Code Playgroud)
如何将上面的验证代码用于以下变量?
$idgroup = Session::get('invitation_userid');
Run Code Online (Sandbox Code Playgroud) 有没有办法在laravel 8中定义路由组的名称?
我正在尝试为卖家建立前往订单管理网站的路线,下面是我在web.php 中的路线列表
use App\Http\Controllers\Seller\OrderController;
Route::group(['prefix' => 'seller', 'middleware' => 'auth', 'as' => 'seller.', 'namespace' => 'Seller'], function () {
Route::redirect('/','seller/orders');
Route::resource('/orders', [OrderController::class]);
});
Run Code Online (Sandbox Code Playgroud)
错误
ErrorException
Array to string conversion
at C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php:416
412? protected function getResourceAction($resource, $controller, $method, $options)
413? {
414? $name = $this->getResourceRouteName($resource, $method, $options);
415?
? 416? $action = ['as' => $name, 'uses' => $controller.'@'.$method];
417?
418? if (isset($options['middleware'])) {
419? $action['middleware'] = $options['middleware'];
420? }
1 C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php:416
Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Array to string conversion", "C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php", ["orders", …Run Code Online (Sandbox Code Playgroud)