Commit ab4dc49f authored by Jack Stupple's avatar Jack Stupple

answers and characters modifiers are returned selected with the players...

answers and characters modifiers are returned selected with the players selected currency. If none defined then default back to EUR (should be impossible, should)
parent fce268f1
......@@ -19,10 +19,17 @@ class Answer extends Model
public function modifiers()
{
$selected_currency = Player::select('currency_id')->where('session_id', '=', $_SERVER['HTTP_SESSION_ID'])->firstOrFail();
return $this->hasMany(\App\Modifier::class, 'model_id')
->where('model', '=', 'answer')
->where('currency_id', '=', $selected_currency);
$selected_currency = Player::select('currency_id')->where('session_id', '=', $_SERVER['HTTP_SESSION_ID'])->first();
if ($selected_currency) {
return $this->hasMany(\App\Modifier::class, 'model_id')
->where('model', '=', 'answer')
->where('currency_id', '=', $selected_currency->id);
} else {
$default_currency = Currency::where('currency_code', 'EUR')->firstOrFail();
return $this->hasMany(\App\Modifier::class, 'model_id')
->where('model', '=', 'answer')
->where('currency_id', '=', $default_currency->id);
}
}
public function resourceCategories()
......
......@@ -17,7 +17,18 @@ class Character extends Model
public function baseModifiers()
{
return $this->hasMany(Modifier::class, 'model_id')->where('model', '=', 'character');
$selected_currency = Player::select('currency_id')->where('session_id', '=', $_SERVER['HTTP_SESSION_ID'])->first();
if ($selected_currency) {
return $this->hasMany(Modifier::class, 'model_id')
->where('model', '=', 'character')
->where('currency_id', '=', $selected_currency->id);
} else {
$default_currency = Currency::where('currency_code', 'EUR')->firstOrFail();
return $this->hasMany(Modifier::class, 'model_id')
->where('model', '=', 'character')
->where('currency_id', '=', $default_currency->id);
}
}
public function getAvailableQuestionsAttribute()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment