Reputation: 2231
User model
public function take($id){
return $this->find($id);
}
public function kill(){
return $this->delete();
}
Route Error 1
Route::get('delete/{userid}', function($id)
{
$user = new User;
$user->take($id); //result the content of $id
$user->kill();
});
i can't delete record with these route and only show blank page (without error).
Route errror 2
Route::get('delete/{userid}', function($id)
{
User::take($id)->kill();
});
And with above route i get error Non-static method User::take() should not be called statically
But i can delete with this route
Route::get('show/{userid}', function($id)
{
$user = new User;
$user->take($id)->kill();
});
Thanks in advance.
Upvotes: 1
Views: 409
Reputation: 2397
Try below :
Route::get('show/{$id}', function($id)
{
$user = new User;
$user->find($id)->kill();
});
I think the param accepted has to have the same things that is passed to the closure.
Upvotes: 1