Download the PHP package iantoo/laravel-greeting-package without Composer
On this page you can find all versions of the php package iantoo/laravel-greeting-package. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-greeting-package
Laravel Greeting Package
Description
The Laravel Greeting package is a lightweight, customizable package that provides personalized greeting messages based on the time of the day. It automatically detects the current time and delivers and appropriate greeting in either English of Kiswahili. If a user is logged in, the greeting is personalized with their first name or email.
Features
- Time based greetings
- User personalization
- Multilanguage support
- Artisan Command
- Easy Integration
Use Cases
- Display personalized greetings on dashboards or welcome pages
- Enhance user experience by acknowledging the time of the day
- Support multilingual applocations
Installation
-
Install the Package:
-
Add the package to your Laravel project using Composer:
-
If you are developing the package locally, include it in your
composer.json
file under therepositories
section: - Then run:
-
Configuration
-
Publish Configuration (Optional):
- Publish the package's configuration file to your application's
config
directory:
- Publish the package's configuration file to your application's
-
Publish Language Files (Optional):
- Publish the package's language files to your application's
resources/lang
directory:
- Publish the package's language files to your application's
-
Set the Application Locale (Optional):
- To use Kiswahili for greetings, set the application's locale to
sw
in your.env
file orconfig/app.php
:
- To use Kiswahili for greetings, set the application's locale to
Usage
-
Display a Greeting in a View:
- Use the
Greeting::greet()
method to display a greeting message in any Blade view:
- Use the
-
Test the Greeting via Artisan Command:
-
Run the custom Artisan command to test the greeting output:
- This command will output a greeting message in the console based on the current time and the logged-in user's status.
-
Example Usage: Greetings
In a Controller:
In a Blade View:
Example Usage: Current Date
To display the current date using the currentDate()
method from the Laravel Greeting Package, follow these steps:
Usage Example
1. Using in a Blade View
If you want to display the current date in a Blade view, you can call the currentDate()
method directly in the view.
Output:
2. Using in a Controller
You can also use the currentDate()
method within a controller and pass the result to your view.
And in your Blade view:
3. Using in an Artisan Command
If you need to use the currentDate()
method in a custom Artisan command, it can be easily integrated.
To run the command:
Output:
Conclusion
By using the currentDate()
method in your Blade views, controllers, or custom Artisan commands, you can easily display the current date in a formatted manner (including the day of the week, month, day in numbers, and year) within your Laravel application. This method is flexible and can be used wherever you need to display the date.
Advanced Usage
-
Customizing Greetings:
- Modify the published configuration or language files to customize the greeting messages.
-
Adding More Languages:
- Add new language files in the
resources/lang
directory under the appropriate locale code to support additional languages.
- Add new language files in the
Deployment
- Deploy your Laravel application as usual. The package will automatically generate the appropriate greeting messages based on the user's language preference and time of day.