-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making orders taking into account shipping costs, discounts
- Loading branch information
vilgefortzz
committed
May 26, 2017
1 parent
39ec66a
commit ea5cf01
Showing
22 changed files
with
306 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Delivery extends Model | ||
{ | ||
protected $table = 'deliveries'; | ||
|
||
public function orders() | ||
{ | ||
return $this->hasMany('App\Order'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Payment extends Model | ||
{ | ||
public function orders() | ||
{ | ||
return $this->hasMany('App\Order'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
database/migrations/2017_05_23_140629_create_payments_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreatePaymentsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('payments', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('name')->unique(); | ||
$table->string('path_to_image')->default('/images/missing.png'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('payments'); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
database/migrations/2017_05_23_140703_create_deliveries_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateDeliveriesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('deliveries', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('name')->unique(); | ||
$table->float('price')->unsigned(); | ||
$table->string('path_to_image')->default('/images/missing.png'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('deliveries'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use App\Delivery; | ||
use Illuminate\Database\Seeder; | ||
|
||
class DeliveriesTableSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
$deliveryMethodsNames = ['InPost Courier', 'InPost paczkomat', 'UPS', 'Poczta Polska']; | ||
$deliveryMethodsPrices = [8, 7, 12, 6]; | ||
$deliveryMethodsImages = ['/images/icons/inPost_courier.png', '/images/icons/inPost_paczkomat.jpg', | ||
'/images/icons/ups.png', '/images/icons/poczta_polska.jpg']; | ||
|
||
|
||
for ($i = 0; $i < count($deliveryMethodsNames); $i++) { | ||
factory(Delivery::class)->create([ | ||
'name' => $deliveryMethodsNames[$i], | ||
'price' => $deliveryMethodsPrices[$i], | ||
'path_to_image' => $deliveryMethodsImages[$i] | ||
]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use App\Payment; | ||
use Illuminate\Database\Seeder; | ||
|
||
class PaymentsTableSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
$paymentMethodsNames = ['Credit card', 'Usual transfer']; | ||
$paymentMethodsImages = ['/images/icons/credit_card.png', '/images/icons/usual_transfer.png']; | ||
|
||
for ($i = 0; $i < count($paymentMethodsNames); $i++) { | ||
factory(Payment::class)->create([ | ||
'name' => $paymentMethodsNames[$i], | ||
'path_to_image' => $paymentMethodsImages[$i] | ||
]); | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.