php - Joining tables with slug and id in Laravel 5 -
i very new laravel , trying learn how code in way you're supposed to.
i have 2 tables, user
table , profiles
table, when load profile, fetches data user table based on profile. uses slug load profile.
as trying learn laravel , trying learn build queries wondering following possible 1 query using join? if how do it?
public function index($slug) { $profile_data = profile::where('slug',$slug)->first(); $user_data = user::where('id',$profile_data->user_id)->first(); return view('profile',['profile' => $profile_data, 'user' => $user_data]); }
Comments
Post a Comment