标签 Lumen 中的文章

laravel lumen with 软删除的数据

重点:$query->withTrashed(); $info = self::with('userInfo', 'express.company') ->with(['product' => function ($query) { $query->withTrashed(); }]) ->where($where) ->select(['id', 'type', 'user_id', 'order_sn', 'membership_card_type', 'membership_card_id', 'membership_card_info', 'membership_card_offer_fee', 'coupon_id', 'coupon_info', 'coupon_offer_fee', 'original_price', 'delivery_fee', 'pay_type', 'price', 'remarks', 'status', 'extend_info', 'created_at']) ->orderBy('id', 'desc') ->first();……

阅读全文

lumen cors跨域问题

1,创建CrossHttp中间件 <?php /** * Created by PhpStorm. * User: cnbattle * Date: 18-10-22 * Time: 下午12:40 */ namespace App\Http\Middleware; use Closure; class CrossHttp { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($request->getMethod() == "OPTIONS") { $allowOrigin = [ 'http://admin.580xb.cn', ]; $Origin = $request->header("Origin"); if (in_array($Origin, $allowOrigin)) { return response()->json('ok', 200, [ # 下面参数视request中header而定 'Access-Control-Allow-Origin' => $Origin, 'Access-Control-Allow-Headers' => 'x-requested-with,content-type,Authorization,CityCode', 'Access-Control-Allow-Methods' => 'POST,DELETE,GET,PUT,OPTIONS']); } else { return response()->json('fail', 405); } } $response = $next($request); $response->header('Access-Control-Allow-Origin', '*'); return $response; } } 2……

阅读全文

最近文章

分类

标签

友情链接

其它