Skip to content

Commit 641cb3f

Browse files
authored
Merge pull request #17 from w3bdesign/dev
Add guarded property to all models
2 parents 52a429e + 772d5f8 commit 641cb3f

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

app/Models/Category.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
class Category extends Model
99
{
1010
use HasFactory;
11+
12+
protected $guarded = [];
1113
}

app/Models/Order.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
class Order extends Model
99
{
1010
use HasFactory;
11+
12+
protected $guarded = [];
1113
}

app/Models/Product.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
class Product extends Model
99
{
1010
use HasFactory;
11+
12+
protected $guarded = [];
1113
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateCategoryProductTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('category_product', function (Blueprint $table) {
17+
$table->integer('category_id');
18+
$table->integer('product_id');
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
Schema::dropIfExists('category_product');
30+
}
31+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateOrderProductTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('order_product', function (Blueprint $table) {
17+
$table->integer('order_id');
18+
$table->integer('product_id');
19+
$table->integer('quantity')->default(1);
20+
});
21+
}
22+
23+
/**
24+
* Reverse the migrations.
25+
*
26+
* @return void
27+
*/
28+
public function down()
29+
{
30+
Schema::dropIfExists('order_product');
31+
}
32+
}

0 commit comments

Comments
 (0)