我遇到 simplexml_load_string 函数的问题,该函数之前可以工作,但今天停止工作。
这是输入 xml 的示例:-
$response = '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.beautyfort.com/api/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns1:ProductSearchResponse><ns1:TestMode>false</ns1:TestMode><ns1:Page>1</ns1:Page><ns1:ResultsPerPage>1</ns1:ResultsPerPage><ns1:TotalResults>1276</ns1:TotalResults><ns1:Items><ns1:Item><ns1:StockCode>L3720</ns1:StockCode><ns1:Name>David Beckham Instinct Gift Set 30ml EDT + 150ml Shower Gel</ns1:Name><ns1:QuantityAvailable>1</ns1:QuantityAvailable><ns1:UnitPrice Currency="GBP"><ns1:Amount>8.72</ns1:Amount></ns1:UnitPrice><ns1:YourRating xsi:nil="true"/><ns1:YourStockCode></ns1:YourStockCode><ns1:ImageLastUpdated>2016-12-22 18:13:08</ns1:ImageLastUpdated><ns1:ThumbnailImageUrl>https://www.beautyfort.com/pic/Y0NqeTBJbmdvaUx6ZUFOa0MyTlNObmhGckltYnVQQmg%3D</ns1:ThumbnailImageUrl><ns1:HighResImageUrl xsi:nil="true"/></ns1:Item></ns1:Items></ns1:ProductSearchResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>';
$xml = simplexml_load_string(($response));
//This returning following response:-
SimpleXMLElement Object (
)
Run Code Online (Sandbox Code Playgroud)
有人可以看看这个并让我知道这里出了什么问题吗?
我有三个角色:1. Admin2. Client3.Store
我有三张表:1. users2. roles3.role_user
我怎样才能获得所有拥有该角色的用户Client?
我试过这个
$clients = User::roles()->where('App\Models\Role',Role::CLIENT)->get();
Run Code Online (Sandbox Code Playgroud)
我收到以下错误。
不应静态调用非静态方法 App\Models\User::roles()
好榜样
class Role extends Model
{
public const ADMIN = 'Admin';
public const CLIENT = 'Client';
public const STORE = 'Store';
public function users()
{
return $this->belongsToMany('App\Models\User')->using('App\Models\UserRole');
}
}
Run Code Online (Sandbox Code Playgroud)
用户模型
class User extends Authenticatable
{
use Notifiable;
protected $fillable = [
'name',
'first_name',
'last_name',
'email',
'password',
'activated',
'token',
'signup_ip_address',
'signup_confirmation_ip_address',
'signup_sm_ip_address',
'admin_ip_address',
'updated_ip_address',
'deleted_ip_address',
];
protected $hidden = …Run Code Online (Sandbox Code Playgroud)