What seems to be the problem:
I’m trying to create an Inventory manager, currently working on the Order page
What I currently have going is a “select” for adding products. This adds the selected product(s) model to a collection $orderProducts.
Would I be better off just storing the IDs instead of models? If so, how can I optimally fetch all product data to display in the list?
Are you using the latest version of Livewire:
Yes
Do you have any screenshots or code examples:
// Livewire Component
public $allProducts;
public $orderProducts;
public $newProduct = null;
public function mount() {
$this->allProducts = Product::all();
$this->orderProducts = collect();
}
public function addProduct() {
if($this->newProduct !== null) {
$product = Product::find($this->newProduct);
$this->orderProducts->push($product->toArray());
$this->newProduct = null;
}
}