更新代码
This commit is contained in:
70
app/Http/Controllers/Controller.php
Normal file
70
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use RuLong\Area\Models\Area;
|
||||
use RuLong\Order\Models\Order;
|
||||
use Session;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, AjaxResponse;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
if ($request['share_uid']) {
|
||||
session(['parent_id' => $request['share_uid']]);
|
||||
}
|
||||
|
||||
// $this->middleware('auth');
|
||||
|
||||
//检查是否有礼品
|
||||
self::checkGift();
|
||||
}
|
||||
|
||||
//获取当前定位数组
|
||||
public function getDefaultLocation()
|
||||
{
|
||||
$lat = session('lat', '45.76021');
|
||||
$lng = session('lng', '126.66835');
|
||||
$city = session('city', '');
|
||||
$area = session('area', '');
|
||||
$real_area = session('real_area', '');
|
||||
$history_area = session('history_area', '');
|
||||
if (!$area) {
|
||||
$area = Area::where('sn', '230100')->first();
|
||||
}
|
||||
|
||||
if (!$real_area) {
|
||||
session::put('real_area', $area);
|
||||
$real_area = session('real_area', '');
|
||||
}
|
||||
$location = [
|
||||
'lat' => $lat,
|
||||
'lng' => $lng,
|
||||
'city' => $city,
|
||||
'area' => $area,
|
||||
'real_area' => $real_area,
|
||||
'history_area' => $history_area,
|
||||
];
|
||||
return $location;
|
||||
}
|
||||
|
||||
public function checkGift()
|
||||
{
|
||||
if (Auth::user()) {
|
||||
$gift = Order::where('user_id', Auth::id())->where('item_type', 'GIFT')->where('state', 'UNADDRESS')->first();
|
||||
if ($gift) {
|
||||
$url = ($gift->type == 'lesson') ? route('gifts.unpay') : route('lottery.logs', ['type' => 'goods']);
|
||||
View::share('show_gift_url', $url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user