-
packages/Webkul/Product/src/Repositories/ProductRepository.php
Open in GitHubuse Illuminate\Container\Container; use Webkul\Core\Eloquent\Repository; use Webkul\Attribute\Repositories\AttributeValueRepository; class ProductRepository extends Repository { protected $attributeValueRepository; public function __construct( AttributeValueRepository $attributeValueRepository, Container $container ) { $this->attributeValueRepository = $attributeValueRepository; parent::__construct($container); } public function create(array $data) { $product = parent::create($data); $this->attributeValueRepository->save($data, $product->id); return $product; } // }
-
packages/Webkul/Admin/src/Http/Controllers/Product/ProductController.php
Open in GitHubuse Illuminate\Support\Facades\Event; use Webkul\Admin\Http\Controllers\Controller; use Webkul\Attribute\Http\Requests\AttributeForm; use Webkul\Product\Repositories\ProductRepository; class ProductController extends Controller { protected $productRepository; public function __construct(ProductRepository $productRepository) { $this->productRepository = $productRepository; request()->request->add(['entity_type' => 'products']); } // public function store() { Event::dispatch('product.create.before'); $product = $this->productRepository->create(request()->all()); Event::dispatch('product.create.after', $product); session()->flash('success', trans('admin::app.products.create-success')); return redirect()->back(); } // }