Created
January 27, 2015 10:40
-
-
Save coreymcmahon/9ddf1a8fb240a887f121 to your computer and use it in GitHub Desktop.
ProductsController.php - A Pattern for Reusable Resource Controllers in Laravel 4.2 http://slashnode.com/reusable-resource-controllers/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Controllers\Admin; | |
use App\Controllers\BaseResourceController; | |
use App\Models\Products; | |
use App\Repositories\Products; | |
use App\Validators\Product as ProductValidator; | |
class ProductsController extends BaseResourceController | |
{ | |
public function __construct(Product $model, Products $repo, ProductValidator $validator) | |
{ | |
$this->model = $model; | |
$this->repo = $repo; | |
$this->validator = $validator; | |
} | |
/** | |
* @return string | |
*/ | |
protected function userRole() | |
{ | |
return 'admin'; | |
} | |
/** | |
* @return string | |
*/ | |
protected function resourceName() | |
{ | |
return 'products'; | |
} | |
/** | |
* @param null $entity_id | |
* @return array|void | |
*/ | |
protected function formData($entity_id = null) | |
{ | |
$categories = \App::make('App\Repositories\Categories')->all(); | |
return [ | |
'categories' => $categories | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment