生成[App\Http\Controllers\PushNotifController,Kreit\Fireba



我正在使用Laravel 9和Firebase作为数据库。这表明我制作的控制器在构建时是不可实例化的。我在youtube上关注了文档和频道,WEB IT的Funda。但它仍然不起作用。

建议的意见:

  • "具有权威的URI的路径必须以斜线"开头/"或者是空的,我得到了这个错误">
  • "如果有人得到一个";Kreit\Firebase\Exception\InvalidArgumentException:具有权限的URI的路径必须以斜杠"开头/"或者在文件"中为空;只需添加一个"/"在您的表名之前">

试过这两个,但都没用。或者我把"/"?我把";"push_notif";,如"/push_notif"。但仍然有同样的错误。

我的控制器:

<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use KreaitFirebaseDatabase;
class PushNotifController extends Controller
{
public function __construct(Database $database){
$this->database = $database;
$this->tablename = 'push_notif';
}
public function push(Request $request){
$postData = [
'notif_title' => $request->notif_title,
'notif_desc' => $request->notif_desc,
];
$postRef = $this->database->getReference($this->tablename)->push($postData);
if ($postRef){

return redirect('notification')->with('status', 'Notification has been pushed.');
}else{
return redirect('notification')->with('status', 'Notification pushing failed.');
}
}
}

发生这种情况是因为您引用的是
Kreit\Firebase\Database,而不是Kreit\ Firebase\合同\数据库

相关内容

最新更新