@csrf @php $user_role = auth()->user()->role; $admin = 1; $auth_staff = 0; $auth_branch = 3; $auth_client = 4; $userBranch = Modules\Cargo\Entities\Branch::where('user_id',auth()->user()->id)->first(); $userStaff = Modules\Cargo\Entities\Staff::where('user_id',auth()->user()->id)->first(); $userClient = Modules\Cargo\Entities\Client::where('user_id',auth()->user()->id)->first(); $branches = Modules\Cargo\Entities\Branch::where('is_archived', 0)->get(); $clients = Modules\Cargo\Entities\Client::where('is_archived', 0)->get(); if($user_role == $auth_branch){ $branches = Modules\Cargo\Entities\Branch::where('id', $userBranch->id)->get(); $clients = Modules\Cargo\Entities\Client::where('branch_id', $userBranch->id )->get(); }elseif(auth()->user()->can('create-shipments') && $user_role == $auth_staff){ $branches = Modules\Cargo\Entities\Branch::where('id', $userStaff->branch_id )->get(); $clients = Modules\Cargo\Entities\Client::where('branch_id', $userStaff->branch_id )->get(); } $countries = Modules\Cargo\Entities\Country::where('covered',1)->get(); $packages = Modules\Cargo\Entities\Package::all(); $deliveryTimes = Modules\Cargo\Entities\DeliveryTime::all(); // is_def_mile_or_fees if result 1 for mile if result 2 for fees $is_def_mile_or_fees = Modules\Cargo\Entities\ShipmentSetting::getVal('is_def_mile_or_fees'); if(!$is_def_mile_or_fees){ $is_def_mile_or_fees = 0; } $googleSettings = resolve(\app\Models\GoogleSettings::class)->toArray(); $googleMap = json_decode($googleSettings['google_map'], true); $google_map_key = ''; if($googleMap){ $google_map_key = $googleMap['google_map_key']; } $paymentSettings = resolve(\Modules\Payments\Entities\PaymentSetting::class)->toArray(); @endphp