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
3d6a9a16
Commit
3d6a9a16
authored
Nov 01, 2022
by
TTS Tran Viet Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update mgration 1
parent
cb3f3dc8
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
67 additions
and
18 deletions
+67
-18
Post.php
app/Models/Post.php
+5
-0
PostCategory.php
app/Models/PostCategory.php
+14
-0
Product.php
app/Models/Product.php
+4
-0
ProductCategory.php
app/Models/ProductCategory.php
+14
-0
User.php
app/Models/User.php
+1
-1
2014_10_12_000000_create_users_table.php
database/migrations/2014_10_12_000000_create_users_table.php
+4
-4
2022_10_31_070501_create_products_table.php
...se/migrations/2022_10_31_070501_create_products_table.php
+4
-3
2022_10_31_070520_create_posts_table.php
database/migrations/2022_10_31_070520_create_posts_table.php
+5
-4
2022_10_31_070547_create_product_attributes_table.php
...ons/2022_10_31_070547_create_product_attributes_table.php
+2
-2
2022_10_31_071157_create_settings_table.php
...se/migrations/2022_10_31_071157_create_settings_table.php
+2
-2
2022_10_31_100142_create_product_categories_table.php
...ons/2022_10_31_100142_create_product_categories_table.php
+6
-1
2022_10_31_100202_create_post_categories_table.php
...ations/2022_10_31_100202_create_post_categories_table.php
+6
-1
No files found.
app/Models/Post.php
View file @
3d6a9a16
...
@@ -8,6 +8,11 @@
...
@@ -8,6 +8,11 @@
class
Post
extends
Model
class
Post
extends
Model
{
{
const
STATUS_DRAFT
=
1
;
const
STATUS_PUBLISHED
=
2
;
const
STATUS_FUTURE_PUBLISH
=
3
;
const
STATUS_DELETED
=
4
;
use
HasFactory
, SoftDeletes
;
use
HasFactory
, SoftDeletes
;
protected
$guarded
=
[];
protected
$guarded
=
[];
...
...
app/Models/PostCategory.php
View file @
3d6a9a16
...
@@ -8,6 +8,10 @@
...
@@ -8,6 +8,10 @@
class
PostCategory
extends
Model
class
PostCategory
extends
Model
{
{
const
STATUS_ENABLE
=
1
;
const
STATUS_DISABLE
=
2
;
const
STATUS_DELETED
=
3
;
use
HasFactory
, SoftDeletes
;
use
HasFactory
, SoftDeletes
;
protected
$guarded
=
[];
protected
$guarded
=
[];
...
@@ -16,4 +20,14 @@ public function posts()
...
@@ -16,4 +20,14 @@ public function posts()
{
{
return
$this
->
hasMany
(
Post
::
class
);
return
$this
->
hasMany
(
Post
::
class
);
}
}
public
function
parent
()
{
return
$this
->
hasMany
(
PostCategory
::
class
);
}
public
function
children
()
{
return
$this
->
belongsTo
(
PostCategory
::
class
,
'parent_id'
);
}
}
}
app/Models/Product.php
View file @
3d6a9a16
...
@@ -8,6 +8,10 @@
...
@@ -8,6 +8,10 @@
class
Product
extends
Model
class
Product
extends
Model
{
{
const
STATUS_ENABLE
=
1
;
const
STATUS_DISABLE
=
2
;
const
STATUS_DELETED
=
3
;
use
HasFactory
, SoftDeletes
;
use
HasFactory
, SoftDeletes
;
protected
$guarded
=
[];
protected
$guarded
=
[];
...
...
app/Models/ProductCategory.php
View file @
3d6a9a16
...
@@ -8,6 +8,10 @@
...
@@ -8,6 +8,10 @@
class
ProductCategory
extends
Model
class
ProductCategory
extends
Model
{
{
const
STATUS_ENABLE
=
1
;
const
STATUS_DISABLE
=
2
;
const
STATUS_DELETED
=
3
;
use
HasFactory
, SoftDeletes
;
use
HasFactory
, SoftDeletes
;
protected
$guarded
=
[];
protected
$guarded
=
[];
...
@@ -16,4 +20,14 @@ public function products()
...
@@ -16,4 +20,14 @@ public function products()
{
{
return
$this
->
hasMany
(
Product
::
class
);
return
$this
->
hasMany
(
Product
::
class
);
}
}
public
function
parent
()
{
return
$this
->
hasMany
(
ProductCategory
::
class
);
}
public
function
children
()
{
return
$this
->
belongsTo
(
ProductCategory
::
class
,
'parent_id'
);
}
}
}
app/Models/User.php
View file @
3d6a9a16
...
@@ -18,7 +18,7 @@ class User extends Authenticatable
...
@@ -18,7 +18,7 @@ class User extends Authenticatable
*
*
* @var array<int, string>
* @var array<int, string>
*/
*/
protected
$guard
=
[];
protected
$guard
ed
=
[];
/**
/**
* The attributes that should be hidden for serialization.
* The attributes that should be hidden for serialization.
...
...
database/migrations/2014_10_12_000000_create_users_table.php
View file @
3d6a9a16
...
@@ -15,10 +15,10 @@ public function up()
...
@@ -15,10 +15,10 @@ public function up()
{
{
Schema
::
create
(
'users'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
id
();
$table
->
string
(
'
username'
,
50
);
$table
->
string
(
'
name'
);
$table
->
string
(
'email'
,
50
)
->
unique
();
$table
->
string
(
'email'
)
->
unique
();
$table
->
string
(
'phone'
,
20
);
$table
->
string
(
'phone'
);
$table
->
string
(
'address'
,
255
);
$table
->
string
(
'address'
);
$table
->
timestamp
(
'email_verified_at'
)
->
nullable
();
$table
->
timestamp
(
'email_verified_at'
)
->
nullable
();
$table
->
string
(
'password'
);
$table
->
string
(
'password'
);
$table
->
rememberToken
();
$table
->
rememberToken
();
...
...
database/migrations/2022_10_31_070501_create_products_table.php
View file @
3d6a9a16
<?php
<?php
use
App\Models\Product
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Support\Facades\Schema
;
...
@@ -15,13 +16,13 @@ public function up()
...
@@ -15,13 +16,13 @@ public function up()
{
{
Schema
::
create
(
'products'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'products'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
id
();
$table
->
string
(
'name'
,
50
);
$table
->
string
(
'name'
);
$table
->
string
(
'image'
,
255
);
$table
->
string
(
'image'
);
$table
->
text
(
'description'
);
$table
->
text
(
'description'
);
$table
->
decimal
(
'price'
,
8
,
2
);
$table
->
decimal
(
'price'
,
8
,
2
);
$table
->
unsignedInteger
(
'product_category_id'
);
$table
->
unsignedInteger
(
'product_category_id'
);
$table
->
unsignedInteger
(
'stock'
);
$table
->
unsignedInteger
(
'stock'
);
$table
->
unsignedTinyInteger
(
'status'
);
$table
->
unsignedTinyInteger
(
'status'
)
->
default
(
Product
::
STATUS_ENABLE
)
;
$table
->
softDeletes
();
$table
->
softDeletes
();
$table
->
timestamps
();
$table
->
timestamps
();
});
});
...
...
database/migrations/2022_10_31_070520_create_posts_table.php
View file @
3d6a9a16
<?php
<?php
use
App\Models\Post
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Support\Facades\Schema
;
...
@@ -15,12 +16,12 @@ public function up()
...
@@ -15,12 +16,12 @@ public function up()
{
{
Schema
::
create
(
'posts'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'posts'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
id
();
$table
->
string
(
'title'
,
255
);
$table
->
string
(
'title'
);
$table
->
text
(
'content'
);
$table
->
text
(
'content'
)
->
nullable
()
->
default
(
null
)
;
$table
->
unsignedInteger
(
'user_id'
);
$table
->
unsignedInteger
(
'user_id'
);
$table
->
unsignedInteger
(
'post_category_id'
);
$table
->
unsignedInteger
(
'post_category_id'
);
$table
->
date
(
'publish_date'
);
$table
->
date
(
'publish_date'
)
->
nullable
()
;
$table
->
unsignedTinyInteger
(
'status'
);
$table
->
unsignedTinyInteger
(
'status'
)
->
default
(
Post
::
STATUS_DRAFT
)
;
$table
->
softDeletes
();
$table
->
softDeletes
();
$table
->
timestamps
();
$table
->
timestamps
();
});
});
...
...
database/migrations/2022_10_31_070547_create_product_attributes_table.php
View file @
3d6a9a16
...
@@ -15,8 +15,8 @@ public function up()
...
@@ -15,8 +15,8 @@ public function up()
{
{
Schema
::
create
(
'product_attributes'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'product_attributes'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
id
();
$table
->
string
(
'size'
,
50
);
$table
->
string
(
'size'
);
$table
->
string
(
'color'
,
50
);
$table
->
string
(
'color'
);
$table
->
unsignedInteger
(
'quantity'
);
$table
->
unsignedInteger
(
'quantity'
);
$table
->
unsignedInteger
(
'product_id'
);
$table
->
unsignedInteger
(
'product_id'
);
$table
->
softDeletes
();
$table
->
softDeletes
();
...
...
database/migrations/2022_10_31_071157_create_settings_table.php
View file @
3d6a9a16
...
@@ -15,8 +15,8 @@ public function up()
...
@@ -15,8 +15,8 @@ public function up()
{
{
Schema
::
create
(
'settings'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'settings'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
id
();
$table
->
string
(
'code'
,
255
);
$table
->
string
(
'code'
);
$table
->
string
(
'name'
,
255
);
$table
->
string
(
'name'
);
$table
->
longText
(
'value'
);
$table
->
longText
(
'value'
);
$table
->
softDeletes
();
$table
->
softDeletes
();
$table
->
timestamps
();
$table
->
timestamps
();
...
...
database/migrations/2022_10_31_100142_create_product_categories_table.php
View file @
3d6a9a16
<?php
<?php
use
App\Models\ProductCategory
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Support\Facades\Schema
;
...
@@ -15,7 +16,11 @@ public function up()
...
@@ -15,7 +16,11 @@ public function up()
{
{
Schema
::
create
(
'product_categories'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'product_categories'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
id
();
$table
->
string
(
'name'
,
50
);
$table
->
string
(
'name'
);
$table
->
string
(
'image'
);
$table
->
unsignedInteger
(
'parent_id'
);
$table
->
unsignedTinyInteger
(
'status'
)
->
default
(
ProductCategory
::
STATUS_ENABLE
);
$table
->
unsignedInteger
(
'ordering'
);
$table
->
softDeletes
();
$table
->
softDeletes
();
$table
->
timestamps
();
$table
->
timestamps
();
});
});
...
...
database/migrations/2022_10_31_100202_create_post_categories_table.php
View file @
3d6a9a16
<?php
<?php
use
App\Models\PostCategory
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Support\Facades\Schema
;
...
@@ -15,7 +16,11 @@ public function up()
...
@@ -15,7 +16,11 @@ public function up()
{
{
Schema
::
create
(
'post_categories'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'post_categories'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
id
();
$table
->
string
(
'name'
,
50
);
$table
->
string
(
'name'
);
$table
->
string
(
'image'
);
$table
->
unsignedInteger
(
'parent_id'
);
$table
->
unsignedTinyInteger
(
'status'
)
->
default
(
PostCategory
::
STATUS_ENABLE
);
$table
->
unsignedInteger
(
'ordering'
);
$table
->
softDeletes
();
$table
->
softDeletes
();
$table
->
timestamps
();
$table
->
timestamps
();
});
});
...
...
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