提交代码
This commit is contained in:
47
app/Http/Controllers/Controller.php
Normal file
47
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use RuLong\Area\Models\Area;
|
||||
use Session;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, AjaxResponse;
|
||||
|
||||
//获取当前定位数组
|
||||
public function getDefaultLocation()
|
||||
{
|
||||
$lat = session('lat', '45.76021');
|
||||
$lng = session('lng', '126.66835');
|
||||
$area = session('area', '');
|
||||
$real_area = session('real_area', '');
|
||||
|
||||
if (!$area) {
|
||||
$area = Area::where('sn', '230100')->first();
|
||||
}
|
||||
|
||||
if (!$real_area) {
|
||||
session::put('real_area', $area);
|
||||
$real_area = $area;
|
||||
}
|
||||
|
||||
$location = [
|
||||
'lat' => $lat,
|
||||
'lng' => $lng,
|
||||
'area' => $area,
|
||||
'real_area' => $real_area,
|
||||
];
|
||||
return $location;
|
||||
}
|
||||
|
||||
public function getDefault($value)
|
||||
{
|
||||
$location = $this->getDefaultLocation();
|
||||
return $location[$value] ?? '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user