• REST to be continued

resource Controller really makes your work easy

HTTP VERB Path Controller Action/method
GET /Users Index
GET /Users/create Create
POST /Users Store
GET /Users/{id} Show (individual record)
GET /Users/{id}/edit Edit
PUT /Users/{id} Update
DELETE /Users/{id} Delete

Editing user information

{{ link_to_route('users.edit', 'Edit', array($user->id), array('class'
=> 'btn btn-info')) }}
public function edit($id)
$user = User::find($id);
if (is_null($user))return Redirect::route('users.index');
return View::make('users.edit', compact('user'));

link_to_route function will generate a link /users//edit, which will call the resourceful Controller user, and Controller will bind it with the edit method.

Other examples.

//in controller fetch the user object using the following code:
$users = User::all();

then index.blade.php whould look like (table of users with Edit & Delete buttons): @if ($users->count())

Username Password Email Phone Name
{{ $user->username }} {{ $user->password }} {{ $user->email }} {{ $user->phone }} {{ $user->name }} {{ link_to_route('users.edit', 'Edit', array($user->id), array('class' => 'btn btn-info')) }} {{ Form::open(array('method' => 'DELETE', 'route' => array('users.destroy', $user->id))) }} {{ Form::submit('Delete', array('class' => 'btn btn-danger')) }} {{ Form::close() }}

@else There are no users @endif @stop

Leave a Comment

Fields with * are required.

Please enter the letters as they are shown in the image above.
Letters are not case-sensitive.