I have similar application, and I settled for query based on username instead of id. Another option is to have username as primary key (if usernames are unique)
Hmm okay... well I think I'd add an index to the field. Sorry I wasn't being totally specific, it isn't a user name, it's actually a first name and last name - IDEALLY it would look like this (sorry should have said before):
www.site.com/{firstname}{lastname[0]}/
so for John Doe it would be:
So this being the case there is no unique constraint on first name or last name. One workaround I thought would be to make it {firstname}{lastname[0]}/{id}, which would suffice.
edit: I don't reckon I'd get the first index of the variable like that, but just for the sake of explanation.
Yeah I guess I'll just go with ID for now. This idea is sort of in conjunction with the theme of the website, but it's not an essential requirement. Thanks for taking a look anyway.
What you should do is in your link do this:
yourpage.blade.php:
{{ URL::route('routename',$user->id) }}
in routes:
Route::get('/page/{id}',array( 'as'=>'routname', 'uses'=>'YourController@getId' ));
controller:
public function getId($id) {
$user = DB::table('users')->where('id','=',$id);
$user->delete();
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community