Homparty dev
This commit is contained in:
parent
9252094a04
commit
ac0d5b781e
60 changed files with 3443 additions and 293 deletions
|
|
@ -9,6 +9,7 @@ use App\Models\Product;
|
|||
use App\Models\ProductAttribute;
|
||||
use App\Models\ProductCategory;
|
||||
use App\Models\ProductImage;
|
||||
use App\Models\ProductIngredient;
|
||||
|
||||
class ProductRepository extends BaseRepository {
|
||||
|
||||
|
|
@ -40,12 +41,32 @@ class ProductRepository extends BaseRepository {
|
|||
|
||||
$this->updateCategories(isset($data['categories']) ? $data['categories'] : array());
|
||||
$this->updateAttributes(isset($data['attributes']) ? $data['attributes'] : array());
|
||||
$this->updateIngredients(isset($data['product_ingredients']) ? $data['product_ingredients'] : array());
|
||||
$this->updateCountryPrices($data);
|
||||
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
|
||||
public function updateIngredients($data = array())
|
||||
{
|
||||
$ProductIngredient = $this->model->p_ingredients()->pluck('ingredient_id')->toArray();
|
||||
//set attr
|
||||
if(is_array($data)){
|
||||
foreach ($data as $id) {
|
||||
//not use
|
||||
if(!in_array($id, $ProductIngredient)){
|
||||
ProductIngredient::create([
|
||||
'product_id' => $this->model->id,
|
||||
'ingredient_id' => $id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateCategories($data = array())
|
||||
{
|
||||
foreach ($this->model->categories as $category) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue