davide-casiraghi / php-responsive-random-quote
A package that shows responsive random quotes
Requires
- astrotomic/laravel-translatable: ^11.1
- guzzlehttp/guzzle: ^6.3
- mcamara/laravel-localization: ^1.3
- nesbot/carbon: ^2.17
Requires (Dev)
- orchestra/testbench: ~3.0
- phpunit/phpunit: ^7.5
README
Laravel Reponsive Random Quotes
Show a random quote or the quote of the day in your PHP Laravel project.
The package support multi language trough dimsav/laravel-translatable and mcamara/laravel-localization packages.
Installation
Require the package using composer:
composer require davide-casiraghi/php-responsive-random-quote
Publish the files from the service provider
php artisan vendor:publish --force
And then pick the number of the related service provider.
Create the DB tables
php artisan migrate
This will create in your databases two new tables: quotes and quote_translations.
Import the _responsive-quote.scss file in /resources/scss/app.scss
@import 'vendor/responsive-quotes/responsive-quote';
and then run in console:
npm run dev
Usage
Add quotes to the database table
The package adds in the application in which it is installed the route /php-responsive-quote/
From this route it's possible to add, edit and remove the quotes and their translations.
Show a random quote
use DavideCasiraghi\PhpResponsiveRandomQuote\QuoteFactory; $quote = PhpResponsiveQuote::getRandomQuote();
Then in any blade file is possible include the view like this:
@include('vendor.responsive-quotes.show-random-quote', [ 'quoteAuthor' => $quote['author'], 'quoteText' => $quote['text'], ])
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Testing
You can run unit tests checking the code coverage using this command.
./vendor/bin/phpunit --coverage-html=html
So you can find the reports about the code coverage in this file /html/index.html