Added option for admins to upload background image for users
This commit is contained in:
parent
142fdd0d7b
commit
5665465076
|
@ -220,6 +220,7 @@ public function users(Request $request)
|
|||
$littlelink_name = $request->littlelink_name;
|
||||
$littlelink_description = $request->littlelink_description;
|
||||
$role = $request->role;
|
||||
$customBackground = $request->file('background');
|
||||
|
||||
if ($request->password == '') {
|
||||
User::where('id', $id)->update(['name' => $name, 'email' => $email, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role]);
|
||||
|
@ -228,7 +229,19 @@ public function users(Request $request)
|
|||
}
|
||||
if (!empty($profilePhoto)) {
|
||||
$profilePhoto->move(base_path('/img'), $id . ".png");
|
||||
}
|
||||
}
|
||||
if (!empty($customBackground)) {
|
||||
$directory = base_path('/img/background-img/');
|
||||
$files = scandir($directory);
|
||||
$pathinfo = "error.error";
|
||||
foreach($files as $file) {
|
||||
if (strpos($file, $id.'.') !== false) {
|
||||
$pathinfo = $id. "." . pathinfo($file, PATHINFO_EXTENSION);
|
||||
}}
|
||||
if(file_exists(base_path('/img/background-img/').$pathinfo)){File::delete(base_path('/img/background-img/').$pathinfo);}
|
||||
|
||||
$customBackground->move(base_path('/img/background-img/'), $id.".".$request->file('background')->extension());
|
||||
}
|
||||
|
||||
return redirect('panel/users/all');
|
||||
}
|
||||
|
|
|
@ -37,16 +37,19 @@
|
|||
@endif
|
||||
@if(file_exists(base_path("img/" . $user->id . ".png")))<br><a title="Remove icon" class="hvr-grow p-1 text-danger" style="padding-left:5px;" href="?delete"><i class="bi bi-trash-fill"></i> Delete</a>@endif
|
||||
@if($_SERVER['QUERY_STRING'] === 'delete' and File::exists(base_path('img/' . $user->id . '.png')))@php File::delete(base_path('img/' . $user->id . '.png')); header("Location: ".url()->current()); die(); @endphp @endif
|
||||
</div>
|
||||
</div><br>
|
||||
|
||||
<div class="form-group col-lg-8">
|
||||
<label>Custom background</label><br>
|
||||
<label>Custom background</label>
|
||||
<input type="file" class="form-control-file" name="background">
|
||||
</div>
|
||||
<div class="form-group col-lg-8">
|
||||
@if(!file_exists(base_path('/img/background-img/'.findBackground($user->id))))<p><i>No image selected</i></p>@endif
|
||||
<img style="width:95%;max-width:400px;argin-left:1rem!important;border-radius:5px;" src="@if(file_exists(base_path('/img/background-img/'.findBackground($user->id)))){{url('/img/background-img/'.findBackground($user->id))}}@else{{url('/littlelink/images/themes/no-preview.png')}}@endif">
|
||||
@if(file_exists(base_path('/img/background-img/'.findBackground($user->id))))<br><a title="Remove icon" class="hvr-grow p-1 text-danger" style="padding-left:5px;" href="?deleteB"><i class="bi bi-trash-fill"></i> Delete</a>@endif
|
||||
@if($_SERVER['QUERY_STRING'] === 'deleteB' and File::exists(base_path('/img/background-img/'.findBackground($user->id))))@php File::delete(base_path('/img/background-img/'.findBackground($user->id))); header("Location: ".url()->current()); die(); @endphp @endif
|
||||
<br>
|
||||
</div>
|
||||
</div><br>
|
||||
|
||||
<!--<div class="form-group col-lg-8">
|
||||
<label>Littlelink name </label>
|
||||
|
|
Loading…
Reference in New Issue