### Running Database Migration for Laravel Love (v7 to v8) Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This shell command executes the automated database migration process required when upgrading Laravel Love from v7 to v8. It's crucial to back up your production database before running this command, and `doctrine/dbal` must be installed. ```Shell php artisan love:upgrade-v7-to-v8 ``` -------------------------------- ### Installing Laravel Love Package via Composer Source: https://github.com/cybercog/laravel-love/blob/master/README.md This command installs the `cybercog/laravel-love` package into your Laravel project using Composer. It adds the package as a dependency, allowing you to use its features for adding emotional reactions to models. ```shell script $ composer require cybercog/laravel-love ``` -------------------------------- ### Running Laravel Love Database Migrations Source: https://github.com/cybercog/laravel-love/blob/master/README.md After installing the package, this command executes the necessary database migrations for Laravel Love. It creates the required tables and columns in your database to store reaction data. ```shell script $ php artisan migrate ``` -------------------------------- ### Adding 'created_at' and 'updated_at' Columns to 'love_like_counters' Table in MySQL Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This SQL command adds nullable `created_at` and `updated_at` timestamp columns to the `love_like_counters` table. These columns are essential for tracking the creation and last modification times of counter records, aligning with Laravel's conventions. ```mysql ALTER TABLE `love_like_counters` ADD COLUMN `created_at` TIMESTAMP NULL DEFAULT NULL AFTER `count`, ADD COLUMN `updated_at` TIMESTAMP NULL DEFAULT NULL AFTER `created_at`; ``` -------------------------------- ### Updating 'migrations' Table for 'love_like_counters' in MySQL Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This SQL command updates the `migrations` table to reflect the new name of the migration file for the `love_like_counters` table. This is essential for maintaining consistency within Laravel's migration history and proper tracking. ```mysql UPDATE `migrations` SET `migration` = '2016_09_02_163301_create_love_like_counters_table' WHERE `migration` = '2016_09_02_163301_create_like_counter_table' LIMIT 1; ``` -------------------------------- ### Running PHPUnit Tests in Laravel Love (Shell) Source: https://github.com/cybercog/laravel-love/blob/master/CONTRIBUTING.md This command executes the PHPUnit test runner for the Laravel Love project. It's used to verify the functionality and ensure no regressions are introduced during development or bug fixes. This command assumes PHPUnit is installed as a Composer dependency within the `vendor/bin` directory. ```Shell $ vendor/bin/phpunit ``` -------------------------------- ### Syncing 'updated_at' with 'created_at' in 'love_likes' Table (MySQL) Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This optional SQL command updates the newly added `updated_at` column in the `love_likes` table, setting its value to match the `created_at` column for existing records where `updated_at` is null. This ensures historical data has a valid `updated_at` timestamp. ```mysql UPDATE `love_likes` SET `updated_at` = `created_at` WHERE `updated_at` IS NULL AND id > 0; ``` -------------------------------- ### Renaming 'like_counter' Table to 'love_like_counters' in MySQL Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This SQL command renames the `like_counter` table to `love_like_counters`. This is part of the upgrade process for the Laravel Love package, standardizing table names for consistency. ```mysql ALTER TABLE `like_counter` RENAME TO `love_like_counters`; ``` -------------------------------- ### Upgrading Laravel Love from v5 to v6 via Artisan Command Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This shell command executes the Artisan migration specifically designed to upgrade the Laravel Love package from version 5 to version 6. It should only be run after all model and database table preparations are completed. A backup of the production database is strongly recommended before execution to prevent data loss. ```shell script php artisan love:upgrade-v5-to-v6 ``` -------------------------------- ### Renaming 'like' Table to 'love_likes' in MySQL Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This SQL command renames the `like` table to `love_likes`. This is a crucial step for upgrading the Laravel Love package to align with its new naming conventions and avoid conflicts. ```mysql ALTER TABLE `like` RENAME TO `love_likes`; ``` -------------------------------- ### Adding 'updated_at' Column to 'love_likes' Table in MySQL Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This SQL command adds a nullable `updated_at` timestamp column to the `love_likes` table, positioned after the `created_at` column. This column is typically used to track the last modification time of records, which is common in Laravel applications. ```mysql ALTER TABLE `love_likes` ADD COLUMN `updated_at` TIMESTAMP NULL DEFAULT NULL AFTER `created_at`; ``` -------------------------------- ### Updating 'migrations' Table for 'love_likes' in MySQL Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This SQL command updates the `migrations` table to reflect the new name of the migration file associated with the `love_likes` table. This ensures that Laravel's migration system correctly tracks the schema changes and prevents re-running old migrations. ```mysql UPDATE `migrations` SET `migration` = '2016_09_02_153301_create_love_likes_table' WHERE `migration` = '2016_09_02_153301_create_like_table' LIMIT 1; ``` -------------------------------- ### Forcing Synchronous Recount with love:recount Command in Laravel Love (v8 to v9) Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This shell command shows how to force a synchronous recount of statistics using the `love:recount` artisan command after upgrading from Laravel Love v8 to v9. The command now defaults to the queue connection, so `--queue-connection=sync` is required for synchronous execution. ```Shell php artisan love:recount --model="App\User" --queue-connection=sync ``` -------------------------------- ### Updating Eloquent Builder for Reactable Scopes in Laravel Love (v8 to v9) Source: https://github.com/cybercog/laravel-love/blob/master/UPGRADING.md This PHP snippet demonstrates how to update your Eloquent models to use the new `ReactableEloquentBuilderTrait` for local scopes after upgrading from Laravel Love v8 to v9. It requires creating a custom Eloquent Builder class, using the trait within it, and declaring its use in the model's `newEloquentBuilder` method. ```PHP /** * @method static UserEloquentBuilder query() */ class User extends Model { public function newEloquentBuilder($query): UserEloquentBuilder { return new UserEloquentBuilder($query); } } class UserEloquentBuilder extends \Illuminate\Database\Eloquent\Builder { use \Cog\Laravel\Love\Reactable\ReactableEloquentBuilderTrait; // Other User model local query scopes } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.