Skip to content

Commit

Permalink
Configurable database table name for storing the cart session id. (#268)
Browse files Browse the repository at this point in the history
* Configurable database table name for storing the cart session id.

Signed-off-by: JuniorE <[email protected]>

* added new line at the ending of .gitignore file

* Update LaraCart.php

* Update .gitignore

Co-authored-by: Luke Policinski <[email protected]>
  • Loading branch information
JuniorE and lukepolo authored Jul 9, 2020
1 parent 450b5fa commit f4b2725
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/config/laracart.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
*/
'cache_prefix' => 'laracart',

/*
|--------------------------------------------------------------------------
| database settings
|--------------------------------------------------------------------------
|
| Here you can set the name of the table you want to use for
| storing and restoring the cart session id.
|
*/
'database' => [

'table' => 'users',

],

/*
|--------------------------------------------------------------------------
| Locale is used to convert money into a readable format for the user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class AddCartSessionIdToUsersTable extends Migration
*/
public function up()
{
if (!(Schema::hasColumn('users', 'cart_session_id'))) {
Schema::table('users', function (Blueprint $table) {
if (!(Schema::hasColumn(config('laracart.database.table'), 'cart_session_id'))) {
Schema::table(config('laracart.database.table'), function (Blueprint $table) {
$table->string('cart_session_id')->nullable()->default(null);
});
}
Expand All @@ -26,8 +26,8 @@ class AddCartSessionIdToUsersTable extends Migration
*/
public function down()
{
if ((Schema::hasColumn('users', 'cart_session_id'))) {
Schema::table('users', function (Blueprint $table) {
if ((Schema::hasColumn(config('laracart.database.table'), 'cart_session_id'))) {
Schema::table(config('laracart.database.table'), function (Blueprint $table) {
$table->dropColumn('cart_session_id');
});
}
Expand Down

0 comments on commit f4b2725

Please sign in to comment.