Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 20 |
| GeofenceController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 20 |
| index | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 10 |
|||
| saveLocations | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 10 |
|||
| <?php | |
| namespace App\Http\Controllers\Admin; | |
| use App\Helpers\PlatformHelper; | |
| use Illuminate\Http\Request; | |
| use App\Http\Controllers\Controller; | |
| use App\Authorizable; | |
| use Spatie\Permission\Models\Role; | |
| use Spatie\Permission\Models\Permission; | |
| use Illuminate\Support\Facades\Validator; | |
| use App\Http\Controllers\Admin\flash; | |
| use App\Models\Admin\UserDetail; | |
| use Session; | |
| use App\Helpers\AttendanceHelper; | |
| use App\Models\Admin\Setting; | |
| use App\Helpers\GeoFenceHelper; | |
| class GeofenceController extends Controller | |
| { | |
| public function index(Request $request) | |
| { | |
| $title = '/Setup/GeoFence'; | |
| $valTeam = AttendanceHelper::getAttendanceTeam($request); | |
| $val = AttendanceHelper::getAttendanceTeam($request); | |
| $valUser = AttendanceHelper::getAttendanceUser($request); | |
| $geoFenceOrgLevel = GeoFenceHelper::getOrgFence(); | |
| // Retrieve check-in and check-out geofence data | |
| $checkinGeo = Setting::where('name', 'checkin_geo')->where('category', 'geofence')->first(); | |
| // dd($checkinGeo); | |
| $checkoutGeo = Setting::where('name', 'checkout_geo')->where('category', 'geofence')->first(); | |
| // If there's no data, set default values | |
| $checkinGeo = $checkinGeo ? json_decode($checkinGeo->value) : (object)['lat' => '', 'lng' => '', 'radius' => '', 'location' => '']; | |
| $checkoutGeo = $checkoutGeo ? json_decode($checkoutGeo->value) : (object)['lat' => '', 'lng' => '', 'radius' => '', 'location' => '']; | |
| return view('administrationForms.GeoFence.GeoFence', compact('title', 'valTeam', 'valUser', 'val', 'checkinGeo', 'checkoutGeo','geoFenceOrgLevel')); | |
| } | |
| public function saveLocations(Request $request) | |
| { | |
| if (auth()->user()->can('Edit Settings module')) { | |
| $geofenceData = $request->input('geofence_data'); | |
| // Prepare and save check-in data | |
| Setting::updateOrCreate( | |
| ['name' => 'checkin_geo', 'category' => 'geofence', 'fieldtype' => 'text'], | |
| ['value' => json_encode($geofenceData['checkin'])] | |
| ); | |
| // Prepare and save check-out data | |
| Setting::updateOrCreate( | |
| ['name' => 'checkout_geo', 'category' => 'geofence', 'fieldtype' => 'text'], | |
| ['value' => json_encode($geofenceData['checkout'])] | |
| ); | |
| return response()->json(['success' => true]); | |
| } else { | |
| return response()->json(['success' => false, 'error' => 'You do not have permission to edit settings.']); | |
| } | |
| } | |
| } |