小编Voi*_* HD的帖子

Laravel - 关系列等于何处?

我试图获取所有记录,其中玩家的关系调用stats()具有列值的东西.我通常会::where('column_name' 'column_value')为玩家表做,但我怎么能得到::关系表的列等于什么?

Player::where('column_name', 'column_value')->get();
Run Code Online (Sandbox Code Playgroud)

但我想检查关系表中的列?

public function roleplay()
{
    return $this->hasOne('App\Database\Frontend\User\Roleplay', 'user_id', 'id');
}
Run Code Online (Sandbox Code Playgroud)

php mysql shoes laravel

15
推荐指数
2
解决办法
9450
查看次数

Laravel Cors(中间件不工作)

我最近尝试在Laravel 5.4中启用CORS,但不幸的是它不想工作.我已经包含了它在下面给出的代码和错误.任何人都可以帮助找出它不工作的原因吗?我已经通过了所需的标题.

我已经将域名重命名为domain.uk,仅用于示例目的,我不打算公开我的网站域名,因为它正在开发中.

路线(制定一条路线::任何用于测试目的,同时开发,通常在生产时它会发布):

Route::group(['domain' => 'api.domain.uk', 'namespace' => 'Api'], function() {
    Route::group(['middleware' => ['cors'], 'prefix' => 'call'], function() {
        Route::get('/rooms/{id}/get-locked-status', 'ApiController@getRoomLockStatus');
        Route::any('/rooms/{id}/update-locked-status', 'ApiController@updateRoomLockStatus');
    });
});
Run Code Online (Sandbox Code Playgroud)

错误:

XMLHttpRequest cannot load http://api.domain.uk/ajax/rooms/1/update-locked-status. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://ice.domain.uk' is therefore not allowed access. The response had HTTP status code 500.
Run Code Online (Sandbox Code Playgroud)

中间件:

namespace App\Http\Middleware;

use Closure;

class Cors
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed …
Run Code Online (Sandbox Code Playgroud)

php laravel

4
推荐指数
3
解决办法
1万
查看次数

标签 统计

laravel ×2

php ×2

mysql ×1

shoes ×1