Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 68 |
| GeneralSettingController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
342 | |
0.00% |
0 / 68 |
| index | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| create | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 12 |
|||
| store | |
0.00% |
0 / 1 |
110 | |
0.00% |
0 / 48 |
|||
| show | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| edit | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| update | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| destroy | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| Wo_ValidEmail | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 3 |
|||
| <?php | |
| namespace App\Http\Controllers\Setting; | |
| use App\Http\Controllers\Controller; | |
| use Illuminate\Http\Request; | |
| use App\Models\Admin\Setting; | |
| use App\Models\Admin\Timezone; | |
| use App\Helpers\AttendanceHelper; | |
| use Session; | |
| use Illuminate\Support\Facades\Artisan; | |
| class GeneralSettingController extends Controller | |
| { | |
| /** | |
| * Display a listing of the resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function index() | |
| { | |
| } | |
| /** | |
| * Show the form for creating a new resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function create(Request $request) | |
| { | |
| Artisan::call('cache:clear'); | |
| Artisan::call('config:clear'); | |
| Artisan::call('route:clear'); | |
| Artisan::call('view:clear'); | |
| $title = '/Manage Setting'; | |
| $timezones = Timezone::Orderby('name')->get(); | |
| $setting = Setting::pluck('value', 'name')->all(); // Setting::all(); | |
| // $setting=[]; | |
| // foreach($settings as $value) { | |
| // $setting[$value['name']] = $value['value']; | |
| // } | |
| // For Attendance Grace period | |
| $AttendanceGrace = Setting::where('name', 'applied_before')->value('value'); | |
| // For Attendance Marking | |
| $val = AttendanceHelper::getAttendanceMarkValue(); | |
| $valTeam = AttendanceHelper::getAttendanceTeam($request); | |
| $valUser = AttendanceHelper::getAttendanceUser($request); | |
| return view('administrationForms.Setting.generalSetting', compact('title','timezones','val','valTeam','valUser','AttendanceGrace'))->with('setting',$setting); | |
| } | |
| /** | |
| * Store a newly created resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function store(Request $request) | |
| { | |
| if(auth()->user()->can('Edit Settings module')){ | |
| // check email id is vaild or not | |
| if($request['MAIL_FROM_ADDRESS']){ | |
| $result = $this->Wo_ValidEmail($request['MAIL_FROM_ADDRESS']); | |
| if($result == false){ | |
| return redirect()->back()->with('error', 'MAIL FROM ADDRESS should be an email'); | |
| } | |
| } | |
| $arrData = array( | |
| 'user_default_role'=>$request['user_default_role'], | |
| 'time_zone'=>$request['time_zone'], | |
| 'language'=>$request['language'], | |
| 'date_format'=>$request['date_format'], | |
| 'time_format'=>$request['time_format'], | |
| 'week_starts'=>$request['week_starts'], | |
| 'default_employee_type'=>$request['default_employee_type'], | |
| 'default_employee_id'=>$request['default_employee_id'], | |
| 'applied_before'=>$request['applied_before'], | |
| 'time_format_save' => 'H:i:s', | |
| 'MAIL_MAILER'=>$request['MAIL_MAILER'], | |
| 'MAIL_HOST'=>$request['MAIL_HOST'], | |
| 'MAIL_PORT'=>$request['MAIL_PORT'], | |
| 'MAIL_USERNAME'=>$request['MAIL_USERNAME'], | |
| 'MAIL_PASSWORD'=>$request['MAIL_PASSWORD'], | |
| 'MAIL_ENCRYPTION'=>$request['MAIL_ENCRYPTION'], | |
| 'MAIL_DRIVER'=>$request['MAIL_DRIVER'], | |
| 'MAIL_FROM_ADDRESS'=>$request['MAIL_FROM_ADDRESS'], | |
| 'MAIL_FROM_NAME'=>$request['MAIL_FROM_NAME'], | |
| 'sms_provider'=>$request['sms_provider'], | |
| 'gup_shup_username'=>$request['gup_shup_username'], | |
| 'gup_shup_password'=>$request['gup_shup_password'], | |
| 'msg91_auth_key'=>$request['msg91_auth_key'], | |
| 'msg91_sender_id'=>$request['msg91_sender_id'], | |
| 'msg91_route'=>$request['msg91_route'], | |
| ); | |
| if($request['default_employee_id'] == 'automatic') | |
| { | |
| $arrData['default_id'] = $request['txtdefaultid']; | |
| $arrData['id_starts_from'] = $request['txtstartfrom']; | |
| } | |
| if( $request['date_format'] == 'mm/dd/yyyy' ) { | |
| $arrData['php_date_format'] = 'm/d/Y'; | |
| } else if( $request['date_format'] == 'dd/mm/yyyy' ) { | |
| $arrData['php_date_format'] = 'd/m/Y'; | |
| } else { | |
| $arrData['php_date_format'] = 'Y/m/d'; | |
| } | |
| if( $request['time_format'] == 'g:i A' ) { | |
| $arrData['time_format_js'] = 'hh:mm A'; | |
| } else { | |
| $arrData['time_format_js'] = 'HH:mm'; | |
| } | |
| // Apply loop over Data array then check data is exist ot not ,if exist then update existing record with new value else create new | |
| foreach ($arrData as $key => $value) { | |
| $keyExist = Setting::where('name', $key)->first(); | |
| if($keyExist){ | |
| Setting::where('name', $key)->update(['name'=>$key, 'value'=>$value]); | |
| }else{ | |
| Setting::create(['name'=>$key, 'value'=> $value, 'category'=> 'general', 'fieldtype'=>'text']); | |
| } | |
| } | |
| return redirect()->back()->with('success', 'Setting Saved Successfully!'); | |
| }else{ | |
| return redirect()->back()->with('warning', 'You not have permission for edit it!'); | |
| } | |
| } | |
| /** | |
| * Display the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function show($id) | |
| { | |
| // | |
| } | |
| /** | |
| * Show the form for editing the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function edit($id) | |
| { | |
| // | |
| } | |
| /** | |
| * Update the specified resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function update(Request $request, $id) | |
| { | |
| // | |
| } | |
| /** | |
| * Remove the specified resource from storage. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function destroy($id) | |
| { | |
| // | |
| } | |
| function Wo_ValidEmail($email) { | |
| if(filter_var($email, FILTER_VALIDATE_EMAIL) !== false) { | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } | |
| } |