Saturday, 15 January 2011

php - Deleting a row and getting back to the current page Laravel -



php - Deleting a row and getting back to the current page Laravel -

hi i'm trying delete row in pivottable called projecttasks , go current page deleted projecttask. here screenshot of view in browser:

link: http://i.imgur.com/0ly4sjl.png

deleting row in projecttasks table works, getting current view doesn't yet work. know why happens. it's because of $project_id variable has no value in projecttaskcontroller. did see value in view before had deleted row in projecttasks table.

i show first error page see on browser:

link: http://i.imgur.com/3tigz45.png

well isn't clear me, see url looks strange. because has double forwards slashes. looks this:

http://localhost/offertetool/public/user/projects//edit

i show had tried:

form.blade.php (view):

@foreach ($project->projecttask $pt) <tr> <td> {{ $pt->task['task_name'] }} </td> <td> {{-- {{ $project->id }} --}} <input type="hidden" name="projectid" value="{{$project->id}}"/> {{-- {{form::hidden('id', $project->id)}} --}} </td> <td> {{ form::text('hour', $pt->hour, array('class' => 'form-control', 'id'=>'hour')) }} </td> <td> {{ form::text('hour_salary', $pt->hour_salary, array('class' => 'form-control', 'id'=>'hour_salary')) }} </td> <td> {{ form::text('total_salary', $pt->total_salary, array('class' => 'form-control', 'id'=>'total_salary', 'disabled')) }} {{-- {{ form::text('total_salary', $project->total_salary, array('class' => 'form-control', 'id'=>'total_salary', 'disabled')) }}--}} </td> <td> <div class="dropdown"> <button type="button" class="btn btn-danger dropdown-toggle seldelete" data-toggle="dropdown"> <input id="check1" name="checkbox[]" type="checkbox" class="check" > <span class="caret-hover caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="seldelete" role="menu"> <li><a href= "{{ route('user.projecttasks.destroy',array( $pt->id )) }}" data-method="delete" >delete</a></li> </ul> </div> </td> </tr> @endforeach

projecttaskscontroller.php :

<?php public function destroy($id) { $project_id=input::get('projectid'); //die(print_r($project_id)); //there no value in $project_id projecttask::destroy($id); //$project = project::find($project_id); homecoming redirect::route('user.projects.edit', array($project_id)); }

and go routes.php:

<?php route::group(array('prefix'=>'user', 'before'=>'auth'),function(){ route::resource('usergroups', 'usergroupscontroller'); route::resource('orders', 'orderscontroller'); route::resource('users', 'userscontroller'); route::resource('tasks', 'taskscontroller'); route::resource('projects', 'projectscontroller'); route::get('orders/destroy/{id}',array('as'=>'user.orders.destroy', 'uses'=>'orderscontroller@destroy')); route::get('users/destroy/{id}',array('as'=>'user.users.destroy', 'uses'=>'userscontroller@destroy')); route::get('projects/destroy/{id}',array('as'=>'user.projects.destroy', 'uses'=>'projectscontroller@destroy')); route::get('projecttasks/destroy/{id}',array('as'=>'user.projecttasks.destroy', 'uses'=>'projecttaskscontroller@destroy')); });

and run edit() method in projectscontroller.php:

public function edit($id) { $project = project::find($id); homecoming view::make('user.projects.edit', compact('project')); }

can help me, please?

php html laravel eloquent blade

No comments:

Post a Comment