I want to insert mysql and redis databases in their classes at the same time. I tried to use the repository pattern, but laravel's bind method implements the interface to only one single class
The controller is as follows:
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());
}
}
PostRepositoryInterface
interface PostRepositoryInterface
{
public function all();
public function get($id);
public function create($param);
public function update($id, $param);
public function delete($id);
}
The question I want to ask is, how can I perform the insert operation in more than one class using this interface?
Aucun commentaire:
Enregistrer un commentaire