我想同时在他们的类中插入mysql和redis数据库。我尝试使用存储库模式,但是 laravel 的 bind 方法只实现了一个类的接口
控制器如下:
class PostController extends Controller
{
protected $post;
public function __construct(PostRepositoryInterface $post)
{
$this->post = $post;
}
public function store(StorePostRequest $request, PostRepositoryInterface $post)
{
return $post->create($request->validated());
}
}
PostRepository接口
interface PostRepositoryInterface
{
public function all();
public function get($id);
public function create($param);
public function update($id, $param);
public function delete($id);
}
我想问的问题是,如何使用这个接口在多个类中执行插入操作?