has('id')) { // return [ // 'id' => $admin->id, // 'name' => $admin->name, // 'username' => $admin->username, // 'mobile' => $admin->mobile, // 'sex' => $admin->sex, // 'email' => $admin->email, //// 'department' => $admin->department, //// 'job' => $admin->job, // 'shop' => $admin->shop, // 'roles' => $admin->roles()->select(['id', 'nickname', 'name'])->get(), // 'last_login_time' => $admin->last_login_time, // 'last_login_ip' => $admin->last_login_ip, //// 'wechat_auth_id' => $admin->wechat_auth_id, //// 'is_view_user_info' => $admin->is_view_user_info, //// 'company_id' => $admin->company_id, //// 'type' => $admin->type, // 'extra_fields' => $admin->extra_fields, // 'status' => $admin->status, // 'created_at' => $admin->created_at ? $admin->created_at->format('Y-m-d H:i:s') : null, // ]; // } $department = $admin->department; if ($admin->shop_id) { $department = $admin->shop; } return [ 'id' => $admin->id, 'name' => $admin->name, 'username' => $admin->username, 'mobile' => $admin->mobile, 'sex' => $admin->sex, 'email' => $admin->email, 'department' =>$department, // 'job' => $admin->job, // 'shop' => $admin->shop, 'roles' => $admin->roles()->select(['id', 'nickname', 'name'])->get(), 'role' => $admin->roles()->select(['id', 'nickname', 'name'])->orderBy('id', 'asc')->first(), 'last_login_time' => $admin->last_login_time, 'last_login_ip' => $admin->last_login_ip, // 'wechat_auth_id' => $admin->wechat_auth_id, // 'is_view_user_info' => $admin->is_view_user_info, // 'company' => $admin->company, 'extra_fields' => $admin->extra_fields, 'type' => $admin->type, 'status' => $admin->status, 'created_at' => $admin->created_at ? $admin->created_at->format('Y-m-d H:i:s') : null, ]; } }