Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
L
laravel_training
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TTS Tran Viet Anh
laravel_training
Commits
cb3f3dc8
Commit
cb3f3dc8
authored
Oct 31, 2022
by
TTS Tran Viet Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update migration
parent
24adea40
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
55 additions
and
58 deletions
+55
-58
Post.php
app/Models/Post.php
+7
-2
PostCategory.php
app/Models/PostCategory.php
+3
-3
Product.php
app/Models/Product.php
+4
-8
ProductAttribute.php
app/Models/ProductAttribute.php
+1
-1
ProductCategory.php
app/Models/ProductCategory.php
+1
-6
User.php
app/Models/User.php
+5
-0
2014_10_12_000000_create_users_table.php
database/migrations/2014_10_12_000000_create_users_table.php
+5
-4
2022_10_31_070501_create_products_table.php
...se/migrations/2022_10_31_070501_create_products_table.php
+5
-4
2022_10_31_070520_create_posts_table.php
database/migrations/2022_10_31_070520_create_posts_table.php
+4
-4
2022_10_31_070547_create_product_attributes_table.php
...ons/2022_10_31_070547_create_product_attributes_table.php
+6
-6
2022_10_31_071157_create_settings_table.php
...se/migrations/2022_10_31_071157_create_settings_table.php
+4
-6
2022_10_31_100142_create_product_categories_table.php
...ons/2022_10_31_100142_create_product_categories_table.php
+5
-6
2022_10_31_100202_create_post_categories_table.php
...ations/2022_10_31_100202_create_post_categories_table.php
+5
-8
No files found.
app/Models/Post.php
View file @
cb3f3dc8
...
...
@@ -12,8 +12,13 @@ class Post extends Model
protected
$guarded
=
[];
public
function
c
ategory
()
public
function
postC
ategory
()
{
return
$this
->
belongsTo
(
Category
::
class
);
return
$this
->
belongsTo
(
PostCategory
::
class
);
}
public
function
user
()
{
return
$this
->
belongsTo
(
User
::
class
);
}
}
app/Models/P
roductPropert
y.php
→
app/Models/P
ostCategor
y.php
View file @
cb3f3dc8
...
...
@@ -6,14 +6,14 @@
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
class
P
roductPropert
y
extends
Model
class
P
ostCategor
y
extends
Model
{
use
HasFactory
, SoftDeletes
;
protected
$guarded
=
[];
public
function
p
roduct
()
public
function
p
osts
()
{
return
$this
->
belongsTo
(
Produc
t
::
class
);
return
$this
->
hasMany
(
Pos
t
::
class
);
}
}
app/Models/Product.php
View file @
cb3f3dc8
...
...
@@ -12,17 +12,13 @@ class Product extends Model
protected
$guarded
=
[];
public
function
c
ategory
()
public
function
productC
ategory
()
{
return
$this
->
belongsTo
(
Category
::
class
);
return
$this
->
belongsTo
(
Product
Category
::
class
);
}
public
function
medium
s
()
public
function
productAttribute
s
()
{
return
$this
->
hasMany
(
Media
::
class
,
'accessible_id'
);
}
public
function
productProperties
(){
return
$this
->
hasMany
(
ProductProperty
::
class
);
return
$this
->
hasMany
(
ProductAttribute
::
class
);
}
}
app/Models/
Media
.php
→
app/Models/
ProductAttribute
.php
View file @
cb3f3dc8
...
...
@@ -6,7 +6,7 @@
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
class
Media
extends
Model
class
ProductAttribute
extends
Model
{
use
HasFactory
, SoftDeletes
;
...
...
app/Models/Category.php
→
app/Models/
Product
Category.php
View file @
cb3f3dc8
...
...
@@ -6,7 +6,7 @@
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
class
Category
extends
Model
class
Product
Category
extends
Model
{
use
HasFactory
, SoftDeletes
;
...
...
@@ -16,9 +16,4 @@ public function products()
{
return
$this
->
hasMany
(
Product
::
class
);
}
public
function
posts
()
{
return
$this
->
hasMany
(
Post
::
class
);
}
}
app/Models/User.php
View file @
cb3f3dc8
...
...
@@ -38,4 +38,9 @@ class User extends Authenticatable
protected
$casts
=
[
'email_verified_at'
=>
'datetime'
,
];
public
function
posts
()
{
return
$this
->
hasMany
(
Post
::
class
);
}
}
database/migrations/2014_10_12_000000_create_users_table.php
View file @
cb3f3dc8
...
...
@@ -15,13 +15,14 @@ public function up()
{
Schema
::
create
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'username'
);
$table
->
string
(
'email'
)
->
unique
();
$table
->
string
(
'phone'
);
$table
->
string
(
'address'
);
$table
->
string
(
'username'
,
50
);
$table
->
string
(
'email'
,
50
)
->
unique
();
$table
->
string
(
'phone'
,
20
);
$table
->
string
(
'address'
,
255
);
$table
->
timestamp
(
'email_verified_at'
)
->
nullable
();
$table
->
string
(
'password'
);
$table
->
rememberToken
();
$table
->
softDeletes
();
$table
->
timestamps
();
});
}
...
...
database/migrations/2022_10_31_070501_create_products_table.php
View file @
cb3f3dc8
...
...
@@ -15,14 +15,15 @@ public function up()
{
Schema
::
create
(
'products'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'name'
);
$table
->
string
(
'name'
,
50
);
$table
->
string
(
'image'
,
255
);
$table
->
text
(
'description'
);
$table
->
decimal
(
'price'
,
8
,
2
);
$table
->
unsignedInteger
(
'category_id'
);
$table
->
decimal
(
'price'
,
8
,
2
);
$table
->
unsignedInteger
(
'
product_
category_id'
);
$table
->
unsignedInteger
(
'stock'
);
$table
->
unsignedTinyInteger
(
'status'
);
$table
->
timestamps
();
$table
->
softDeletes
();
$table
->
timestamps
();
});
}
...
...
database/migrations/2022_10_31_070520_create_posts_table.php
View file @
cb3f3dc8
...
...
@@ -15,14 +15,14 @@ public function up()
{
Schema
::
create
(
'posts'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'
name'
);
$table
->
string
(
'
title'
,
255
);
$table
->
text
(
'content'
);
$table
->
string
(
'author
'
);
$table
->
unsignedInteger
(
'category_id'
);
$table
->
unsignedInteger
(
'user_id
'
);
$table
->
unsignedInteger
(
'
post_
category_id'
);
$table
->
date
(
'publish_date'
);
$table
->
unsignedTinyInteger
(
'status'
);
$table
->
timestamps
();
$table
->
softDeletes
();
$table
->
timestamps
();
});
}
...
...
database/migrations/2022_10_31_070547_create_product_
properti
es_table.php
→
database/migrations/2022_10_31_070547_create_product_
attribut
es_table.php
View file @
cb3f3dc8
...
...
@@ -4,7 +4,7 @@
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateProduct
Properti
esTable
extends
Migration
class
CreateProduct
Attribut
esTable
extends
Migration
{
/**
* Run the migrations.
...
...
@@ -13,14 +13,14 @@ class CreateProductPropertiesTable extends Migration
*/
public
function
up
()
{
Schema
::
create
(
'product_
properti
es'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'product_
attribut
es'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
unsignedInteger
(
'size'
);
$table
->
string
(
'color'
);
$table
->
string
(
'size'
,
50
);
$table
->
string
(
'color'
,
50
);
$table
->
unsignedInteger
(
'quantity'
);
$table
->
unsignedInteger
(
'product_id'
);
$table
->
timestamps
();
$table
->
softDeletes
();
$table
->
timestamps
();
});
}
...
...
@@ -31,6 +31,6 @@ public function up()
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'product_
properti
es'
);
Schema
::
dropIfExists
(
'product_
attribut
es'
);
}
}
database/migrations/2022_10_31_071157_create_settings_table.php
View file @
cb3f3dc8
...
...
@@ -15,13 +15,11 @@ public function up()
{
Schema
::
create
(
'settings'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'logo'
);
$table
->
string
(
'language'
);
$table
->
string
(
'hotline'
);
$table
->
string
(
'email'
);
$table
->
string
(
'address'
);
$table
->
timestamps
();
$table
->
string
(
'code'
,
255
);
$table
->
string
(
'name'
,
255
);
$table
->
longText
(
'value'
);
$table
->
softDeletes
();
$table
->
timestamps
();
});
}
...
...
database/migrations/2022_10_31_
070418_create
_categories_table.php
→
database/migrations/2022_10_31_
100142_create_product
_categories_table.php
View file @
cb3f3dc8
...
...
@@ -4,7 +4,7 @@
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateCategoriesTable
extends
Migration
class
Create
Product
CategoriesTable
extends
Migration
{
/**
* Run the migrations.
...
...
@@ -13,12 +13,11 @@ class CreateCategoriesTable extends Migration
*/
public
function
up
()
{
Schema
::
create
(
'categories'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'
product_
categories'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'category_type'
);
$table
->
string
(
'name'
);
$table
->
timestamps
();
$table
->
string
(
'name'
,
50
);
$table
->
softDeletes
();
$table
->
timestamps
();
});
}
...
...
@@ -29,6 +28,6 @@ public function up()
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'categories'
);
Schema
::
dropIfExists
(
'
product_
categories'
);
}
}
database/migrations/2022_10_31_
070828_create_media
_table.php
→
database/migrations/2022_10_31_
100202_create_post_categories
_table.php
View file @
cb3f3dc8
...
...
@@ -4,7 +4,7 @@
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
Create
Media
Table
extends
Migration
class
Create
PostCategories
Table
extends
Migration
{
/**
* Run the migrations.
...
...
@@ -13,14 +13,11 @@ class CreateMediaTable extends Migration
*/
public
function
up
()
{
Schema
::
create
(
'
media
'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'
post_categories
'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'media_type'
);
$table
->
string
(
'accessible'
);
$table
->
unsignedInteger
(
'accessible_id'
);
$table
->
string
(
'file_path'
);
$table
->
timestamps
();
$table
->
string
(
'name'
,
50
);
$table
->
softDeletes
();
$table
->
timestamps
();
});
}
...
...
@@ -31,6 +28,6 @@ public function up()
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'
media
'
);
Schema
::
dropIfExists
(
'
post_categories
'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment