Closed RemiCollin closed 8 years ago
Mmm, great idea. I may differ on the implementation... Maybe we can simply use the ioc container, and an abstract Cart Model — to avoid config calls in Eloquent relations.
You mean something like :
return $this->hasMany(app()->make('cart_item_class'), "cart_id");
Yes. Now that I see it, your proposal seems closer to me... But it feel to me more clear, especially written like this:
return $this->hasMany(app('CartItem'), "cart_id");
And I would add a Cart interface with the contract, to ensure that the specific implementation is compliant.
An interface is maybe not necessary with a simple check :
app('CartItem') instanceof \Dvlpp\Merx\Models\CartItem;
Well, this implies that you are forced to extend Merx's CartItem... But it makes sense. Ok then, I'm merging!
Allow the use of a user-configured CartItem class with Merx.