Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

Commit

Permalink
add some fields in rents & rentprices #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrille37 committed May 15, 2015
1 parent 58c9e6f commit 2980bbd
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 85 deletions.
13 changes: 8 additions & 5 deletions app/Models/Rent.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,29 @@ class Rent extends Model
'id', // FIXME : should not be there
'buildingIndividual',
'buildingStage',
'buildingHLM',
'buildingName',
'street',
'zipcode',
'city',
'country',
'addrlat',
'addrlng',
'geolocManual' // automatic or manual address geolocalization
'geolocManual', // automatic or manual address geolocalization
'roomsCount',
'kitchenRoom',
'surfaceM2'
];

public static $rules = [
'buildingIndividual'=>'required|boolean',
'buildingStage'=>'',
'buildingName'=>'',
'buildingHLM'=>'required|boolean',
'street'=>'required',
'zipcode'=>'required',
'city'=>'required',
'country'=>'required',
'addrlat'=>'required',
'addrlng'=>'required'
'addrlat'=>'required|numeric',
'addrlng'=>'required|numeric'
];

/**
Expand Down
17 changes: 14 additions & 3 deletions app/Models/RentPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,22 @@ class RentPrice extends Model
// http://laravel.com/docs/5.0/eloquent#soft-deleting
use SoftDeletes;

protected $fillable = ['year', 'price'];
protected $fillable = [
'year',
'month',
'price',
'loads',
'loadsOther',
'loadsOtherText',
];

public static $rules = [
'year'=>'required|numeric',
'price'=>'required|numeric'
'year'=>'required|integer',
'month'=>'required|integer',
'price'=>'required|numeric',
'loads'=>'required|numeric',
'loadsOther'=>'numeric',
'loadsOtherText'=>'numeric',
];

/**
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/2015_05_01_145614_create_rents_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public function up()
Schema::create('rents', function(Blueprint $table)
{
$table->increments('id');
$table->boolean('buildingIndividual');
$table->boolean('buildingIndividual')->nullable();
$table->integer('buildingStage');
$table->string('buildingName');
$table->string('street');
$table->string('zipcode');
$table->string('city');
$table->timestamps();
$table->timestamps(); // Adds created_at and updated_at columns
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function up()
$table->foreign('rent_id')
->references('id')->on('rents')
->onDelete('cascade');
$table->timestamps();
$table->timestamps(); // Adds created_at and updated_at columns
});
}

Expand Down
40 changes: 40 additions & 0 deletions database/migrations/2015_05_14_215734_add_more_rent_data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddMoreRentData extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('rents', function(Blueprint $table)
{
$table->boolean('buildingHLM')->nullable()->after('buildingIndividual');
$table->double('surfaceM2')->default(0.0)->after('buildingHLM');
$table->integer('roomsCount')->default(0)->after('surfaceM2');
$table->boolean('kitchenRoom')->nullable()->after('roomsCount');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('rents', function(Blueprint $table)
{
$table->removeColumn('buildingHLM');
$table->removeColumn('roomsCount');
$table->removeColumn('surfaceM2');
$table->removeColumn('kitchenRoom');
});
}

}
40 changes: 40 additions & 0 deletions database/migrations/2015_05_14_220531_add_more_rentprice_data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddMoreRentpriceData extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('rent_prices', function(Blueprint $table)
{
$table->integer('month')->after('year')->default(0);
$table->double('loads')->after('price')->default(0.0);
$table->double('loadsOther')->default(0.0)->after('loads');
$table->string('loadsOtherText')->nullable()->after('loadsOther');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('rent_prices', function(Blueprint $table)
{
$table->removeColumn('month');
$table->removeColumn('loads');
$table->removeColumn('loadsOther');
$table->removeColumn('loadsOtherText');
});
}

}
Loading

0 comments on commit 2980bbd

Please sign in to comment.