Created
February 23, 2015 13:55
-
-
Save Strernd/954a345aff1af4c96337 to your computer and use it in GitHub Desktop.
This file contains 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\Http\Controllers; | |
use App\Http\Requests; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Http\Request; | |
abstract class CrudController extends Controller { | |
protected $model = null; | |
protected $viewDir = null; | |
protected $singular = null; | |
/** | |
* Display a listing of the resource. | |
* | |
* @return Response | |
*/ | |
public function index() | |
{ | |
return view($this->viewDir.'.index',[$this->singular => $this->model->all()]); | |
} | |
... | |
} | |
<?php namespace App\Http\Controllers; | |
use App\Http\Requests; | |
use App\Http\Controllers\Controller; | |
use App\Banana; | |
use Illuminate\Http\Request; | |
class BananaController extends CrudController { | |
/** | |
* @param Banana $banana | |
*/ | |
function __construct(Banana $banana) { | |
$this->singular = 'banana'; | |
$this->model = $banana; | |
$this->viewDir = 'banana'; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment