initial commit

This commit is contained in:
Behzad Babaei
2020-03-28 17:02:54 +04:30
commit 851454db11
39 changed files with 946 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\Order::class, function (Faker\Generator $faker) {
$quantity = $faker->numberBetween(1, 10);
return [
'quantity' => $quantity,
'discount' => $faker->numberBetween(1, 30),
'total_price' => ($quantity * $faker->numberBetween(1, 200)),
'product_id' => $faker->numberBetween(1, 50),
];
});
View File
@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOrdersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('orders', function (Blueprint $table) {
$table->increments('id');
$table->integer('quantity')->unsigned();
$table->decimal('total_price')->unsigned();
$table->decimal('discount')->unsigned()->default(0);
$table->integer('product_id')->unsigned();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('orders');
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(\App\Order::class, 150)->create();
}
}