我得到的错误,当我换一个资源路线我的自定义中间件
我的中间件:
<?php
namespace App\Http\Middleware;
use Closure;
use Auth;
class Officer
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::check() && Auth::user()->role == 'title_officer') {
return $next($request);
}
// elseif (Auth::check() && Auth::user()->role == 'agent') {
// return redirect('/agent');
// }
// else {
// return redirect('/customer');
// }
}
}
Run Code Online (Sandbox Code Playgroud)
使用中间件的资源路由:
Route::resource('new-order', 'BackendController')->middleware('officer');
Run Code Online (Sandbox Code Playgroud)
我收到错误: …
为什么 Laravel 抛出
InvalidArgumentException('The values under comparison must be of the same type');
例外,当在规则上输入非数字文本(如“test”)时:
public function rules()
{
return [
'account_no' => 'required|numeric|gte:1'
];
}
Run Code Online (Sandbox Code Playgroud)
当预期只是不通过验证并显示消息时:
account_no field must be numeric
如何解决这个异常?
当我想下载 invoice.pdf 时出现错误:-
fopen(project_path\storage\fonts/\071ddd89a9cb147bf5639344caee3fe8.ufm):无法打开流:没有这样的文件或目录
在存储下创建字体文件夹后也出现错误:
“执行时间到”最大执行时间为 30 秒。
我现在该怎么办?
如何使用 更新所有记录request->all(),我有很多列要更新。这是我用于插入多个工作正常的新记录的创建方法的代码。
public function store(Request $request)
{
$teacher = new Teacher;
$teacher::create($request->all());
$teacher->save();
return back()->with('message','Teacher Added Successfully!');
}
Run Code Online (Sandbox Code Playgroud)
这是我尝试过但不起作用的方法
public function update(Request $request, Teacher $teacher)
{
$teachers=$request->all();
$teacher->save();
return back()->with('message','Record Successfully Updated!');
}
Run Code Online (Sandbox Code Playgroud) 我是 Laravel 的新手,并使用 Twitter Bootstrap 的一些帮助创建了一个小程序。
我正在尝试访问此路线:
http://127.0.0.1:8000/posts/create
Run Code Online (Sandbox Code Playgroud)
我收到这些错误:
73427cb411f683691ba00d0846f7eda3c61bff74.php 第 4 行中的 2/2 ErrorException:尝试获取非对象的属性(查看:C:\xampp\htdocs\laravel\alquirozlaravel\resources\views\show-solo.blade.php)
in 73427cb411f683691ba00d0846f7eda3c61bff74.php line 4
at CompilerEngine->handleViewException(object(ErrorException), 1) in PhpEngine.php line 44
at PhpEngine->evaluatePath('C:\\xampp\\htdocs\\laravel\\alquirozlaravel\\storage\\framework\\views/73427cb411f683691ba00d0846f7eda3c61bff74.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'post' => null)) in CompilerEngine.php line 59
at CompilerEngine->get('C:\\xampp\\htdocs\\laravel\\alquirozlaravel\\resources\\views/show-solo.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'post' => null)) in View.php line 137
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in Response.php …Run Code Online (Sandbox Code Playgroud) 我可以使用内存来迁移我的数据库并启动服务器吗?
我的/配置/数据库.php
'sqlite' => array(
'driver' => 'sqlite',
'database' => ':memory:', // fail
// 'database' => 'database', // success
'prefix' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
),
Run Code Online (Sandbox Code Playgroud)
并迁移表并启动laravel服务
$ php artisan migrate:refresh
$ php artisan serve
Run Code Online (Sandbox Code Playgroud)
我使用 driver=sqlite + database=database 一切正常,
我使用driver=sqlite + database=:memory,错误信息来自127:0.0.1 说数据库表尚未创建。
我的http:// localhost:8888 / VGL / public / category / 18?sty = 3
当dd($request->sty);等于3
但是我把$request->sty在whereHas为
未定义的变量:请求
public function show(Request $request, $id)
{
$products = Product::with('features')
->whereHas('features', function ($q) {
return $q->where('id', $request->sty);
})
->where('category_id',17)
->get();
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Spatie 角色权限来处理 Laravel 应用程序中的用户角色。我使用工厂创建了用户factory(App\User::class, 50)->create();,现在一些用户是管理员角色。我想将所有角色替换为订阅者,并且只有一个用户是管理员。
我创建了一个用于生成管理员用户的播种机并为该用户添加了角色
$user = User::create([
'name_first' => 'Admin',
'email' => 'admins@admins.com',
'password' => bcrypt('admins@admins.com')
]);
$user->assignRole('super-admin');
Run Code Online (Sandbox Code Playgroud)
如何使用播种机实现这一目标?或者任何其他选项可用于此?
laravel ×8
dompdf ×1
get-request ×1
invoice ×1
laravel-5 ×1
laravel-5.4 ×1
middleware ×1
php ×1
spatie ×1
sqlite ×1
validation ×1