函数 App\Http\Controllers\PubliciteController::stockpath() 的参数太少,传递了 0 个,预期正好是 1 个
Too few arguments to function App\Http\Controllers\PubliciteController::stockpath(), 0 passed and exactly 1 expected
我使用 laravel 5.6 并且我是这个框架的初学者,我想在 publicite table "name","path",[=28 中存储我的数据库=] 在所有 publicites 中,我制作了一个模态和控制器,并将我的控制器添加到路由中的 api.php,但我收到此错误
Too few arguments to function
App\Http\Controllers\PubliciteController::stockpath(), 0 passed and
exactly 1 expected
这是我的控制器:"PubliciteController":
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\publicite;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Tymon\JWTAuth\Exceptions\JWTException;
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
use Config;
use Artisan;
class PubliciteController extends Controller
{
//enregistre les path des images
public function stockpath ($request){
$input = $request->all();
$validator = Validator::make($input, [
'name'=> 'required',
'url'=> 'required',
'path'=> 'required'
] );
if ($validator -> fails()) {
# code...
return $this->sendError('error validation', $validator->errors());
}
$ads = ads::create($input);
return $this->sendResponse($ads->toArray(), 'Ads created succesfully');
}
}
这是我的模特宣传照:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Publicite extends Model
{
protected $fillable = [
'name','url', 'path',
];
}
这是我的路线:
路线::post('publicite', 'PubliciteController@stockpath');
我的错误在哪里,我使用 post man 我得到了这个错误
下次提问前请先阅读手册。
https://laravel.com/docs/5.7/requests
有写:
要通过依赖注入获取当前 HTTP 请求的实例,您应该在控制器方法上输入 Illuminate\Http\Request class 类型提示。传入的请求实例会被服务容器自动注入:
也就是说没有
public function stockpath ($request){
但是
public function stockpath (Request $request){
我使用 laravel 5.6 并且我是这个框架的初学者,我想在 publicite table "name","path",[=28 中存储我的数据库=] 在所有 publicites 中,我制作了一个模态和控制器,并将我的控制器添加到路由中的 api.php,但我收到此错误
Too few arguments to function App\Http\Controllers\PubliciteController::stockpath(), 0 passed and exactly 1 expected
这是我的控制器:"PubliciteController":
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\publicite;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Tymon\JWTAuth\Exceptions\JWTException;
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
use Config;
use Artisan;
class PubliciteController extends Controller
{
//enregistre les path des images
public function stockpath ($request){
$input = $request->all();
$validator = Validator::make($input, [
'name'=> 'required',
'url'=> 'required',
'path'=> 'required'
] );
if ($validator -> fails()) {
# code...
return $this->sendError('error validation', $validator->errors());
}
$ads = ads::create($input);
return $this->sendResponse($ads->toArray(), 'Ads created succesfully');
}
}
这是我的模特宣传照:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Publicite extends Model
{
protected $fillable = [
'name','url', 'path',
];
}
这是我的路线:
路线::post('publicite', 'PubliciteController@stockpath');
我的错误在哪里,我使用 post man 我得到了这个错误
下次提问前请先阅读手册。
https://laravel.com/docs/5.7/requests
有写:
要通过依赖注入获取当前 HTTP 请求的实例,您应该在控制器方法上输入 Illuminate\Http\Request class 类型提示。传入的请求实例会被服务容器自动注入:
也就是说没有
public function stockpath ($request){
但是
public function stockpath (Request $request){