我正在使用Eloquent存储库来处理Laravel PHP项目。我对存储库的接口文件中的一个声明进行了更改。问题是,当我尝试运行我的程序时,我不断获得' Acme \ repositories \ Eloquent \ EloquentPictureRepository :: create()声明必须与Acme \ repositories \ PictureRepository :: create($)兼容输入)' 错误。
现在我的程序仍在阅读PictureRepository.php'的原始声明。而不是我对它做的更新版本。
PictureRepository.php(接口文件):
接口PictureRepository {
public function all();
public function find($id);
public function findOrFail($id);
/* I added the '$filename' parameter to the function 'create()' */
public function create($input, $filename);
public function update($id, $input);
public function delete($id);
public function forceDelete($id);
public function restore($id);
}
EloquentPictureRepository:
<?php namespace Acme\repositories\Eloquent;
use acme\repositories\PictureRepository;
use app\models\Picture;
class EloquentPictureRepository implements PictureRepository {
/* Added the new parameter to the 'create()' function */
public function create($input, $filename)
{
/* Need this structure in order for photos to actually be displayed. */
$newPicture = new Picture;
$newPicture->picture_name = $input['picture_name'];
$newPicture->picture_path = $filename;
$newPicture->picture_description = $input['picture_description'];
$newPicture->picture_edges = $input['picture_edges'];
$newPicture->picture_stones = $input['picture_stones'];
$newPicture->picture_order = $input['picture_order'];
$newPicture->picture_link = $input['picture_link'];
$newPicture->picture_height = $input['picture_height'];
$newPicture->picture_width = $input['picture_width'];
$newPicture->category = $input['category'];
$newPicture->picture_project = $input['picture_project'];
return $newPicture->save();
}
}
我已尝试同时运行&#39; php artisan dump-autoload&#39;和&#39;作曲家更新&#39;但是我的新作品PictureRepository.php&#39;文件仍未被识别。
答案 0 :(得分:0)
我实际上只是跑了作曲家dump-autoload&#39;现在我的已更新的存储库文件已被识别。
编辑:运行&#39; composer dump-autoload&#39;实际上会影响你的控制器,不允许更新它们。除非绝对必要,否则尽量不要运行此命令。