Edit File: SettingService.php
<?php namespace App\Services\Entity; use Illuminate\Support\Facades\Cache; use Illuminate\Http\Request; use App\Models\SiteSetting; use App\Traits\ReportTrait; use Illuminate\View\View; use Image; class SettingService extends BaseService { /** * Initializes the IntroService class. * * @param SiteSetting $siteSetting */ public function __construct(SiteSetting $siteSetting) { $this->model = $siteSetting; } public function index(): View { $data = Cache::rememberForever('settings', function () { return \App\Services\SettingService::appInformations(SiteSetting::pluck('value', 'key')); }); return view('admin.settings.index', compact('data')); } public function update($request , $id = null) { Cache::forget('settings'); if (!is_dir($path = storage_path('app/public/images/settings'))) { mkdir($path, 0777, true); } foreach ($request->validated() as $key => $val) { if (is_file($val)) { $img = Image::make($val); if ($key == 'default_user') { $thumbsPath = 'storage/images/users/default.png'; } elseif ($key == 'no_data') { $thumbsPath = 'storage/images/no_data.png'; } else { $name = time() . rand(1000000, 9999999) . '.' . $val->getClientOriginalExtension(); $thumbsPath = 'storage/images/settings/' . $name; SiteSetting::where('key', $key)->update(['value' => $name]); } $img->save($thumbsPath); } elseif (!is_null($val)) { SiteSetting::where('key', $key)->update(['value' => $val]); } } Cache::rememberForever('settings', function () { return \App\Services\SettingService::appInformations(SiteSetting::pluck('value', 'key')); }); ReportTrait::addToLog('تعديل الاعدادت'); return ['status' => 'success', 'url' => route('admin.settings.index')]; } public function messageAll(Request $request, $type) { $this->userRepo->messageAll($request->all(), $type); return back()->with('success', 'تم الارسال'); } public function messageOne(Request $request, $type) { $this->userRepo->messageOne($request->all(), $type); return back()->with('success', 'تم الارسال'); } public function sendEmail(Request $request) { $this->settingRepo->sendEmail($request->all()); return back()->with('success', 'تم الارسال'); } }
Back to File Manager