Edit File: SettingService.php
<?php namespace App\Services\Entity; use App\Models\SiteSetting; use App\Traits\ReportTrait; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; 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) { Cache::forget('settings'); foreach ( $request->all() as $key => $val ){ if ( is_file($val)) { $img = Image::make($val); if($key == 'default_user'){ $thumbsPath = 'storage/images/users/default.png'; }else if ($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); }else if($val){ SiteSetting::where( 'key', $key ) -> update( [ 'value' => $val ] ); } } if ($request->is_production) { SiteSetting::where( 'key', 'is_production' ) -> update( [ 'value' => 1 ] ); }else{ SiteSetting::where( 'key', 'is_production' ) -> update( [ 'value' => 0 ] ); } Cache::rememberForever('settings', function () { return \App\Services\SettingService::appInformations(SiteSetting::pluck('value', 'key')); }); ReportTrait::addToLog('تعديل الاعدادت') ; return back()->with('success','تم الحفظ'); } 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