Commit 033d2ac9 authored by Jack Stupple's avatar Jack Stupple

add currency support to modifiers

parent d4a1ecc5
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Currency extends Model
{
}
\ No newline at end of file
......@@ -21,6 +21,11 @@ class Player extends Model
protected $appends = ['progress', 'questions', 'score', 'score_string', 'season_roundup_position'];
public function currency()
{
return $this->belongsTo('App\Currency');
}
public function language()
{
return $this->belongsTo(Language::class);
......
......@@ -26,7 +26,8 @@ function get_player($joins = true)
'character.baseModifiers',
'character.baseModifiers.modifierCategory',
'character.status',
'character.profile_picture'
'character.profile_picture',
'currency'
]);
}
......
<?php
use App\Currency;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCurrenciesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('currencies', function (Blueprint $table) {
$table->increments('id');
$table->string('currency_code');
$table->timestamps();
});
// default currency
$currency = new Currency();
$currency->currency_code = 'EUR';
$currency->save();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('currencies');
}
}
<?php
use App\Currency;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddCurrencySupportToModifiers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$currency = Currency::where('currency_code', 'EUR')->firstOrFail();
Schema::table('modifiers', function (Blueprint $table) use ($currency) {
$table->integer('currency_id')->after('modifier_category_id')->default($currency->id);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('modifiers', function (Blueprint $table) {
$table->dropColumn('currency_id');
});
}
}
<?php
use App\Currency;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddCurrencySupportToPlayers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$currency = Currency::where('currency_code', 'EUR')->firstOrFail();
Schema::table('players', function (Blueprint $table) use ($currency) {
$table->integer('currency_id')->after('language_id')->default($currency->id);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('players', function (Blueprint $table) {
$table->dropColumn('currency_id');
});
}
}
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