Collin Matthews began their career in 2008 as a Freelance Web Developer and Designer. In 2012, they founded Press Foundry, offering custom web infrastructure solutions to clients using the WordPress platform. Since then, they have grown a team across 4 timezones that support clients ranging from startups and small businesses to enterprise and Fortune 500 companies.
<?php
namespace App\Http\Controllers;
use App\Http\Requests\CreateProductRequest;
use App\Http\Requests\UpdateProductRequest;
use App\Repositories\ProductRepository;
use App\Http\Controllers\AppBaseController;
use Illuminate\Http\Request;
use Flash;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
class ProductController extends AppBaseController
{
/** @var ProductRepository */
private $productRepository;
public function __construct(ProductRepository $productRepo)
{
$this->productRepository = $productRepo;
}
/**
* Display a listing of the Product.
*
* @param Request $request
* @return Response
*/
public function index(Request $request)
{
$this->productRepository->pushCriteria(new RequestCriteria($request));
$products = $this->productRepository->all();
return view('products.index')
->with('products', $products);
}
/**
* Show the form for creating a new Product.
*
* @return Response
*/
public function create()
{
return view('products.create');
}
/**
* Store a newly created Product in storage.
*
* @param CreateProductRequest $request
*
* @return Response
*/
public function store(CreateProductRequest $request)
{
$input = $request->all();
$product = $this->productRepository->create($input);
Flash::success('Product saved successfully.');
return redirect(route('products.index'));
}
/**
* Display the specified Product.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
$product = $this->productRepository->findWithoutFail($id);
if (empty($product)) {
Flash::error('Product not found');
Sign up to view 1 direct report
Get started