let's suppose we have 2 users with these usernames:
then you would have 2 folders:
storage/app/john
storage/app/sarah
now to access john's files, you should have in your routes/web.php the following:
Route::get('/file/{username}/{name}','FilesController@getFile');
then in the FilesController
add this function:
public function getFile($username,$name){
if(!Auth::user()){
//user is not logged in
return response(null,403)
}
$auth_user = Auth::user()->username;
if($username === $auth_user){
//continue with the request
$exists = Storage::disk('local')->exists($username .'/'. $name);
if(!$exists){
// file not found
return response(null,404);
}
$file = Storage::get($username .'/'. $name);
return response($file);
}else{
// the user doesn't have access
}
}
i didn't test this so if you had issues let me know
More on laravel storage