Skip to content

Commit 7a5c4a0

Browse files
authored
Finish setting up Order, Product and Category model
Finish setting up Order, Product and Category model
2 parents 6960e49 + 889b76f commit 7a5c4a0

9 files changed

+319
-264
lines changed

app/Models/Category.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Category extends Model
9+
{
10+
use HasFactory;
11+
}

app/Models/Order.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Order extends Model
9+
{
10+
use HasFactory;
11+
}

app/Models/Product.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Product extends Model
9+
{
10+
use HasFactory;
11+
}

database/migrations/2014_10_12_000000_create_users_table.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ public function up()
1717
$table->id();
1818
$table->string('name');
1919
$table->string('email')->unique();
20-
$table->timestamp('email_verified_at')->nullable();
20+
$table->string('address');
21+
$table->string('city');
22+
$table->string('state');
23+
$table->string('zipcode');
2124
$table->string('password');
2225
$table->rememberToken();
2326
$table->timestamps();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateProductsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('products', function (Blueprint $table) {
17+
$table->id();
18+
$table->string('name');
19+
$table->string('slug')->unique();
20+
$table->text('description');
21+
$table->integer('price')->default(0);
22+
$table->timestamps();
23+
});
24+
}
25+
/**
26+
* Reverse the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function down()
31+
{
32+
Schema::dropIfExists('products');
33+
}
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateCategoriesTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('categories', function (Blueprint $table) {
17+
$table->id();
18+
$table->string('name');
19+
$table->string('slug')->unique();
20+
$table->timestamps();
21+
});
22+
}
23+
24+
/**
25+
* Reverse the migrations.
26+
*
27+
* @return void
28+
*/
29+
public function down()
30+
{
31+
Schema::dropIfExists('categories');
32+
}
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateOrdersTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('orders', function (Blueprint $table) {
17+
$table->id();
18+
$table->integer('user_id');
19+
$table->string('transaction_id');
20+
$table->integer('total')->default(0);
21+
$table->timestamps();
22+
});
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function down()
31+
{
32+
Schema::dropIfExists('orders');
33+
}
34+
}

0 commit comments

Comments
 (0)