diff --git a/app/Commands/ToggleFavouriteCommand.php b/app/Commands/ToggleFavouriteCommand.php index 68c3ce74..c4926f91 100644 --- a/app/Commands/ToggleFavouriteCommand.php +++ b/app/Commands/ToggleFavouriteCommand.php @@ -49,7 +49,7 @@ class ToggleFavouriteCommand extends CommandBase return $user != null; } - + private function getEntityBeingFavourited():Favouritable { switch ($this->_resourceType) { @@ -80,10 +80,9 @@ class ToggleFavouriteCommand extends CommandBase $fav = new Favourite(); $fav->$typeId = $this->_resourceId; $fav->user_id = Auth::user()->id; - $fav->created_at = time(); $fav->save(); $isFavourited = true; - + Notification::newFavourite($this->getEntityBeingFavourited(), $fav->user); } diff --git a/app/Commands/ToggleFollowingCommand.php b/app/Commands/ToggleFollowingCommand.php index a9bb9910..60cd49ac 100644 --- a/app/Commands/ToggleFollowingCommand.php +++ b/app/Commands/ToggleFollowingCommand.php @@ -62,10 +62,9 @@ class ToggleFollowingCommand extends CommandBase $follow = new Follower(); $follow->$typeId = $this->_resourceId; $follow->user_id = Auth::user()->id; - $follow->created_at = time(); $follow->save(); $isFollowed = true; - + Notification::newFollower($follow->artist, Auth::user()); } diff --git a/config/database.php b/config/database.php index 048e05bf..9088f5a3 100644 --- a/config/database.php +++ b/config/database.php @@ -74,9 +74,9 @@ return [ 'pgsql' => [ 'driver' => 'pgsql', 'host' => env('POSTGRESQL_DB_HOST', 'localhost'), - 'database' => env('POSTGRESQL_DB_DATABASE', 'forge'), - 'username' => env('POSTGRESQL_DB_USERNAME', 'forge'), - 'password' => env('POSTGRESQL_DB_PASSWORD', ''), + 'database' => env('POSTGRESQL_DB_DATABASE', 'homestead'), + 'username' => env('POSTGRESQL_DB_USERNAME', 'homestead'), + 'password' => env('POSTGRESQL_DB_PASSWORD', 'secret'), 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', diff --git a/database/migrations/2016_06_26_225535_create_comments_table.php b/database/migrations/2016_06_26_225535_create_comments_table.php index 03b3e77f..cc93f9ca 100644 --- a/database/migrations/2016_06_26_225535_create_comments_table.php +++ b/database/migrations/2016_06_26_225535_create_comments_table.php @@ -16,7 +16,7 @@ class CreateCommentsTable extends Migration { { $table->increments('id'); $table->integer('user_id')->unsigned()->index('comments_user_id_foreign'); - $table->string('ip_address', 46); + $table->string('ip_address', 46)->nullable(); $table->text('content', 65535); $table->timestamps(); $table->softDeletes()->index(); diff --git a/database/migrations/2016_06_26_225535_create_favourites_table.php b/database/migrations/2016_06_26_225535_create_favourites_table.php index 7adadee3..630103ac 100644 --- a/database/migrations/2016_06_26_225535_create_favourites_table.php +++ b/database/migrations/2016_06_26_225535_create_favourites_table.php @@ -19,7 +19,7 @@ class CreateFavouritesTable extends Migration { $table->integer('track_id')->unsigned()->nullable()->index(); $table->integer('album_id')->unsigned()->nullable()->index(); $table->integer('playlist_id')->unsigned()->nullable()->index(); - $table->dateTime('created_at')->default('now()')->nullable(); + $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'))->nullable(); }); } diff --git a/database/migrations/2016_06_26_225535_create_playlists_table.php b/database/migrations/2016_06_26_225535_create_playlists_table.php index 98648028..eff9d25e 100644 --- a/database/migrations/2016_06_26_225535_create_playlists_table.php +++ b/database/migrations/2016_06_26_225535_create_playlists_table.php @@ -20,12 +20,12 @@ class CreatePlaylistsTable extends Migration { $table->string('slug'); $table->text('description', 65535); $table->unsignedTinyInteger('is_public')->index(); - $table->integer('track_count')->unsigned()->index(); - $table->integer('view_count')->unsigned(); - $table->integer('download_count')->unsigned(); - $table->integer('favourite_count')->unsigned(); - $table->integer('follow_count')->unsigned(); - $table->integer('comment_count')->unsigned(); + $table->integer('track_count')->unsigned()->default(0)->index(); + $table->integer('view_count')->unsigned()->default(0); + $table->integer('download_count')->unsigned()->default(0); + $table->integer('favourite_count')->unsigned()->default(0); + $table->integer('follow_count')->unsigned()->default(0); + $table->integer('comment_count')->unsigned()->default(0); $table->timestamps(); $table->date('deleted_at')->nullable()->index(); }); diff --git a/database/migrations/2016_06_26_225535_create_resource_users_table.php b/database/migrations/2016_06_26_225535_create_resource_users_table.php index c72f7f5b..19aa47cc 100644 --- a/database/migrations/2016_06_26_225535_create_resource_users_table.php +++ b/database/migrations/2016_06_26_225535_create_resource_users_table.php @@ -20,12 +20,12 @@ class CreateResourceUsersTable extends Migration { $table->integer('album_id')->unsigned()->nullable()->index(); $table->integer('playlist_id')->unsigned()->nullable()->index(); $table->integer('artist_id')->unsigned()->nullable()->index(); - $table->unsignedTinyInteger('is_followed'); - $table->unsignedTinyInteger('is_favourited'); - $table->unsignedTinyInteger('is_pinned'); - $table->integer('view_count'); - $table->integer('play_count'); - $table->integer('download_count'); + $table->unsignedTinyInteger('is_followed')->default(0); + $table->unsignedTinyInteger('is_favourited')->default(0); + $table->unsignedTinyInteger('is_pinned')->default(0); + $table->integer('view_count')->default(0); + $table->integer('play_count')->default(0); + $table->integer('download_count')->default(0); $table->unique(['user_id','track_id','album_id','playlist_id','artist_id'], 'resource_unique'); }); }