Skip to content

Instantly share code, notes, and snippets.

@danjohnson95
Last active May 4, 2017 08:55
Show Gist options
  • Save danjohnson95/fa48d4c45a6c289841612344697978ea to your computer and use it in GitHub Desktop.
Save danjohnson95/fa48d4c45a6c289841612344697978ea to your computer and use it in GitHub Desktop.
<?php namespace App\Http\Controllers;
use App\Repos\ProductRepository;
class ProductController extends Controller
{
/**
* An instance of the Product Repository
* @var \App\Repos\ProductRepository
*/
protected $repo;
/**
* Injects the dependency
* @param \App\Repos\ProductRepository $repo
*/
public function __construct(ProductRepository $repo)
{
$this->repo = $repo;
}
/**
* Gets a product by the ID
* @param int $id
* @return \Illuminate\View\View
*/
public function show($id)
{
$product = $this->repo->findById($id);
return view('product', $product);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment