Edit File: SettingController.php
<?php namespace App\Http\Controllers\Admin; use App\Models\Paymentmethod; use Image ; use App\Traits\Report; use App\Models\Setting; use Illuminate\Http\Request; use App\Services\SettingService; use App\Http\Controllers\Controller; use App\Models\Bank; use Illuminate\Support\Facades\Config; class SettingController extends Controller { /*************************** get all settings **************************/ public function index(){ $data = SettingService::appInformations(Setting::pluck('value', 'key')); $banks = Bank::all(); $methods = Paymentmethod::all(); return view('admin.settings.index',compact('data','banks' , 'methods')); } public function method_update(Request $request) { if($request['cash'] ) { Paymentmethod::where('key' , 'cash')->update(['status'=>'active']); }else{ Paymentmethod::where('key' , 'cash')->update(['status'=>'not_active']); } if($request['online'] ) { Paymentmethod::where('key' , 'online')->update(['status'=>'active']); }else{ Paymentmethod::where('key' , 'online')->update(['status'=>'not_active']); } if($request['wallet']) { Paymentmethod::where('key' , 'wallet')->update(['status'=>'active']); }else{ Paymentmethod::where('key' , 'wallet')->update(['status'=>'not_active']); } Report::addToLog('تعديل الاعدادت') ; return back()->with('success','تم الحفظ'); } /*************************** update settings **************************/ public function update(Request $request){ // dd($request->all()); if($request['site_phone'] && strlen($request['site_phone']) < 10){ return back()->with('danger',trans('auth.invalid_phone')); } foreach ( $request->all() as $key => $val ) if (in_array($key , ['logo' , 'fav_icon' , 'default_user' , 'site_header_image' , 'login_background' , 'google_store'])) { $img = Image::make($val); $name = $key .'.png'; if($key == 'default_user'){ $name = 'default.png'; $thumbsPath = 'assets/uploads/users'; }else if ($key == 'no_data') { $thumbsPath = 'assets/uploads/'; }else{ $thumbsPath = 'assets/uploads/settings'; } $img->save($thumbsPath . '/' . $name); }else if($val){ Setting::where( 'key', $key ) -> update( [ 'value' => $val ] ); } Report::addToLog('تعديل الاعدادت') ; return back()->with('success','تم الحفظ'); } }
Back to File Manager