Rodney Wormsbecher Rodney Wormsbecher - 2 months ago 14
PHP Question

Laravel Route custom route instead of resource

I'm using laravel 5.2 and I am trying to get a custom link from my view to my AdminOfficesController. However for some reason it just gives me a blank page with no errors or whatsoever. Tried to desbug it using the docs, stackoverflow and debugging but I remain clueless of why it doesn't work. Any help is appreciated.

In my view I have the following link:

<a href="{{ url('admin/offices/' . $customer->id) }}">
<div class="float-left">
<button class="btn btn-success btn-xs">Create office</button>

In my routes I have the following code:

Route::get('/', function () {
return view('/auth/login');


Route::get('/home', 'HomeController@index');

Route::resource('admin/users', 'AdminUsersController');
Route::resource('admin/customers', 'AdminCustomersController');
Route::resource('admin/offices', 'AdminOfficesController');
Route::resource('admin/labourentries', 'AdminLabourentriesController');
Route::resource('admin/labourtypes', 'AdminLabourtypesController');
Route::get('/admin/dashboard', 'AdminCustomersController@dashboard');
Route::get('admin/offices/{customer_id}/create', 'AdminOfficesController@create');

And my controller contains the following code:

public function create()
echo "hi";
return view('admin.offices.create');

I'm probably missing something very simple in my view or route file, but I honestly don't see it. My controller's other functions like index etc is working fine.

Thanks for the help .


You could name your routes:

Route::get('/admin/offices/{customer_id}/create', [
    'as' => 'admin.offices.customer.create,
    'uses' => 'AdminOfficesController@create'

And use it like this

<a href="{{URL::route('admin.offices.client.create', array($customer->id))}}">