Turned ll home page into one function

This commit is contained in:
Julian Prieber 2023-03-13 15:32:48 +01:00
parent 03db2656ba
commit b9c0b38260
2 changed files with 7 additions and 19 deletions

View File

@ -77,26 +77,14 @@ class UserController extends Controller
//Show littlelink page. example => http://127.0.0.1:8000/+admin //Show littlelink page. example => http://127.0.0.1:8000/+admin
public function littlelink(request $request) public function littlelink(request $request)
{ {
$littlelink_name = $request->littlelink;
$id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id');
if (empty($id)) { if(env('HOME_URL') !== ""){
return abort(404);
}
$userinfo = User::select('id', 'name', 'littlelink_name', 'littlelink_description', 'theme', 'role')->where('id', $id)->first();
$information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->get();
$links = DB::table('links')->join('buttons', 'buttons.id', '=', 'links.button_id')->select('links.link', 'links.id', 'links.button_id', 'links.title', 'links.custom_css', 'links.custom_icon', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get();
return view('littlelink', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]);
}
//Show littlelink page as home page if set in config
public function littlelinkhome(request $request)
{
$littlelink_name = env('HOME_URL'); $littlelink_name = env('HOME_URL');
$id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id'); $id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id');
}else{
$littlelink_name = $request->littlelink;
$id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id');
}
if (empty($id)) { if (empty($id)) {
return abort(404); return abort(404);

View File

@ -60,7 +60,7 @@ if(config('advanced-config.custom_home_url') != '') {
$custom_home_page_url = "/home"; $custom_home_page_url = "/home";
} }
if(env('HOME_URL') != '') { if(env('HOME_URL') != '') {
Route::get('/', [UserController::class, 'littlelinkhome'])->name('littlelink'); Route::get('/', [UserController::class, 'littlelink'])->name('littlelink');
if(config('advanced-config.disable_home_page') == 'redirect') { if(config('advanced-config.disable_home_page') == 'redirect') {
Route::get($custom_home_page_url, function () {return redirect(config('advanced-config.redirect_home_page'));}); Route::get($custom_home_page_url, function () {return redirect(config('advanced-config.redirect_home_page'));});
}elseif(config('advanced-config.disable_home_page') != 'true') { }elseif(config('advanced-config.disable_home_page') != 'true') {