ClearBowl/api/app/Http/Controllers/ProductsController.php

24 lines
623 B
PHP
Raw Normal View History

2019-12-04 12:49:41 +01:00
<?php
namespace App\Http\Controllers;
use App\Http\Requests\AddProductRequest;
use App\Repositories\ProductsRepositoryInterface;
class ProductsController extends Controller
{
private ProductsRepositoryInterface $productsRepository;
public function __construct(ProductsRepositoryInterface $productsRepository)
{
$this->productsRepository = $productsRepository;
}
public function add(AddProductRequest $request)
{
$product = $this->productsRepository->create($request->all());
return response()->json(['success' => true, 'data' => ['product' => $product]], 200);
}
}