Created
April 23, 2024 21:44
-
-
Save bulentsakarya/3bbcdb10f54ecca892906eecdab3fc50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\Admin\Settings; | |
use App\Http\Controllers\Controller; | |
use App\Http\Requests\Admin\Settings\Settings\AppSettingsUpdateRequest; | |
use App\Models\Setting; | |
use Illuminate\Http\RedirectResponse; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Redirect; | |
use Illuminate\Support\Facades\Storage; | |
use Illuminate\View\View; | |
class AppSettingsController extends Controller | |
{ | |
public function index(): View | |
{ | |
return view('admin.settings.app.index'); | |
} | |
public function update(AppSettingsUpdateRequest $request): RedirectResponse | |
{ | |
$key = 'app'; | |
$data = []; | |
$data['title'] = $request->title; | |
$data['slogan'] = $request->slogan; | |
if($request->hasFile('logo')) { | |
if(Storage::exists(config('panel.logo'))) { | |
Storage::delete(config('panel.logo')); | |
} | |
$logo_name = 'logo.' . $request->logo->extension(); | |
$request->logo->storeAs('logo', $logo_name); | |
$data['logo'] = 'logo/' . $logo_name; | |
} | |
if($request->hasFile('favicon')) { | |
if(Storage::exists(config('panel.favicon'))) { | |
Storage::delete(config('panel.favicon')); | |
} | |
$favicon_name = 'favicon.' . $request->favicon->extension(); | |
$request->favicon->storeAs('favicon', $favicon_name); | |
$data['favicon'] = 'favicon/' . $favicon_name; | |
} | |
$value = json_encode($data); | |
Setting::firstWhere('key', $key)->update([ | |
'value' => $value | |
]); | |
return Redirect::route('panel.settings.app')->with('success', 'Uygulama bilgileri başarılı bir şekilde güncellendi'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="POST" action="{{ route('panel.settings.update.app') }}" | |
enctype="multipart/form-data"> | |
@csrf | |
<div class="card-body"> | |
<div class="mb-3 row"> | |
<label class="col-3 col-form-label required">Uygulama Adı</label> | |
<div class="col"> | |
<input type="text" name="title" class="form-control" aria-describedby="appName" | |
placeholder="Uygulama Adını Giriniz" value="{{ config('panel.title') }}"> | |
<small class="form-hint">Sayfa başlığında ve diğer alanlarda görülecek adı | |
giriniz.</small> | |
</div> | |
</div> | |
<div class="mb-3 row"> | |
<label class="col-3 col-form-label required">Slogan</label> | |
<div class="col"> | |
<input type="text" name="slogan" class="form-control" placeholder="Slogan" | |
value="{{ config('panel.slogan') }}"> | |
<small class="form-hint">Varsa uygulama sloganınızı giriniz.</small> | |
</div> | |
</div> | |
<div class="mb-3 row"> | |
<label class="col-3 col-form-label">Logo</label> | |
<div class="col"> | |
<input type="file" name="logo" class="form-control mb-2"> | |
<div class="d-block"> | |
<img id='preview_logo' class="img-fluid w-50" | |
src="{{ Storage::exists(config('panel.logo')) ? Storage::url(config('panel.logo')) : asset('herkobi.png') }}" | |
alt="Herkobi Logo" /> | |
</div> | |
</div> | |
</div> | |
<div class="mb-3 row"> | |
<label class="col-3 col-form-label">Favicon</label> | |
<div class="col"> | |
<input type="file" name="favicon" class="form-control mb-2"> | |
<div class="d-block"> | |
<img id='preview_favicon' class="img-fluid" | |
src="{{ Storage::exists(config('panel.favicon')) ? Storage::url(config('panel.favicon')) : asset('herkobi-favicon.png') }}" | |
alt="Herkobi Favicon" /> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="card-footer text-end"> | |
<button type="submit" id="updateButton" class="btn btn-primary">Güncelle</button> | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
League\Flysystem\Filesystem::has(): Argument #1 ($location) must be of type string, null given, called in C:\filament\herkobi\vendor\laravel\framework\src\Illuminate\Filesystem\FilesystemAdapter.php on line 181 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Requests\Admin\Settings\Settings; | |
use Illuminate\Foundation\Http\FormRequest; | |
class AppSettingsUpdateRequest extends FormRequest | |
{ | |
/** | |
* Determine if the user is authorized to make this request. | |
*/ | |
public function authorize(): bool | |
{ | |
return true; | |
} | |
/** | |
* Get the validation rules that apply to the request. | |
* | |
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> | |
*/ | |
public function rules(): array | |
{ | |
return [ | |
'title' => ['required', 'string', 'max:255'], | |
'slogan' => ['string', 'max:255'], | |
'logo' => ['nullable','image', 'max:1024', 'mimes:jpg,jpeg,png,svg'], | |
'favicon' => ['nullable','image', 'max:512', 'mimes:png'], | |
]; | |
} | |
/** | |
* Get the error messages for the defined validation rules. | |
* | |
* @return array<string, string> | |
*/ | |
public function messages(): array | |
{ | |
return [ | |
/** | |
* Title Messages | |
*/ | |
'title.required' => 'Lütfen uygulama adını giriniz', | |
'title.string' => 'Lütfen geçerli bir uygulama adı giriniz', | |
'title.max' => 'Lütfen uygulama adını daha kısa giriniz', | |
/** | |
* Slogan Messages | |
*/ | |
'slogan.string' => 'Lütfen uygulama sloganını giriniz', | |
'slogan.max' => 'Lütfen daha kısa uygulama sloganı giriniz', | |
/** | |
* Logo Messages | |
*/ | |
'logo.image' => 'Lütfen geçerli bir resim yükleyiniz', | |
'logo.max' => 'Lütfen daha düşük boyutta bir resim yükleyiniz', | |
'logo.mimes' => 'Lütfen jpg, jpeg ya da png formatında bir resim yükleyiniz', | |
/** | |
* Favicon Messages | |
*/ | |
'favicon.image' => 'Lütfen geçerli bir resim yükleyiniz', | |
'favicon.max' => 'Lütfen daha düşük boyutta bir resim yükleyiniz', | |
'favicon.mimes' => 'Lütfen jpg, jpeg ya da png formatında bir resim yükleyiniz', | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment