weizong song 5 years ago
parent 11e4b051ac
commit 449b2b5587

@ -153,13 +153,24 @@ class AuthController extends Controller
}
/**
* Get the authenticated User.
*
* @return \Illuminate\Http\JsonResponse
* @OA\Post(
* path="/manager/me",
* summary="V2-获取登录者信息",
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* description="",
* @OA\Response(
* response="200",
* description="获取登录者信息"
* )
* )
*/
public function me()
{
return response()->json($this->guard()->user());
$id = $this->guard()->id();
$manager = (new Manager())->with(["projects" => function ($query) {
$query->select("project.id", "project.name", "project.address", "project.latitude", "project.longitude");
}])->select("id", "name", "username", "openid", "type", "sex", "mobile", "avatar")->find($id);
return response()->json($manager->toArray());
}
/**

@ -583,14 +583,11 @@ class OrdersController extends CommonController
return response()->json($res);
break;
case "alipay":
$res = (new WxMicroPay())->pay($recharge);
if ($res !== true) {
return response()->json([
"errorcode" => 60003,
"errormsg" => $res->getMessage()
]);
}
return response()->json($res);
//todo:支付宝支付实现
return response()->json([
"errorcode" => 60003,
"errormsg" => "支付宝支付方式尚未开通,敬请期待"
]);
break;
default:
return response()->json([

@ -56,7 +56,23 @@ class Manager extends Authenticatable implements JWTSubject
use Notifiable;
CONST GUARD_NAME = "manager";
public $appends = ["type_name"];
public $appends = ["type_name","avatar_url"];
public function getAvatarUrlAttribute()
{
$protocol = request()->secure() ? "https" : "http";
if (!$this->avatar) {
switch ($this->sex) {
case "男":
$this->avatar = "/images/male.png";
break;
case "女":
$this->avatar = "/images/female.png";
break;
}
}
return $this->avatar ? $protocol . "://" . request()->getHost() . $this->avatar : $this->avatar;
}
public function getTypeNameAttribute()
{

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateManagerAddAvatar extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table("managers",function (Blueprint $table) {
$table->string("avatar")->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
Loading…
Cancel
Save