Im very new to Laravel. It seems there are a few ways to get things done so Im looking for best practice on multipart page load.
In php I might have loaded all I need in a function and passed all my objects/results as vars then use the vars as needed on the page.
- this has the drawback of a large function plus individual functions for refreshing part of the content with AJAX
Here I send all vars to page on load, it returns view, so I cant use this function later for page part
// load full page with vars for parts
// ( will require other functions for separate requests later )
public function profilepage(){
// do query set result as var to be passed
// do query set result as var to be passed
// do query set result as var to be passed
return view('profiles.profile', ['data'=>$data,'social'=>$social,'exper'=>$experience]);
}
With Laravel, we have routes that are pretty flexible to get exactly what we need.
- so it seems I would want to set all my page parts as routes to individual functions on Load
- then use those same functions for refresh with AJAX?
Would this load the page while also loading the page parts? Is the best way to multi-part content?
// load page
Route::get('/profile', 'ProfileController@profile');
// get page parts
Route::get('/profile', 'ProfileController@profile')->('get.social_content');
Route::get('/profile', 'ProfileController@profile')->('get.job_content');
Route::get('/profile', 'ProfileController@profile')->('get.experience_content');