hgacreative / hga-laravel-preset
The default Laravel presets for HGA-based applications
Installs: 75
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/hgacreative/hga-laravel-preset
Requires
- php: >=7.1.3
- doctrine/dbal: *
- guzzlehttp/guzzle: *
- laravel/passport: *
Requires (Dev)
This package is auto-updated.
Last update: 2025-10-08 05:56:40 UTC
README
This package is intended to be used by employees and colleagues of HGA, but has been made public as the wider community may also benefit from some of these presets. A list of the tweaks we have made are documented below.
App
Models
- Moved the
App\Usermodel into an appointedModelsfolder (App\Models), which we favour the structure of for cleaner code on larger projects - Updates the
Usermodel to break down the "name" column into "first name" and "last name" - Creates a
Rolemodel, including relationship to theUsermodel
Controllers
- Updated the Auth controllers to not redirect to
/homebecause this route no longer exists - Updated any reference of the
Usermodel to beApp\Models\User - Added a
PageController.phpfor handling our default index route to take the closure away from theweb.phproutes file
Providers
- Updated the default name of the Laravel Passport cookie
- Added a Gate to determine if the user is an admin or not. By default, this option is not used when first running the hga preset
- Added a boilerplate for a View Composer Service Provider. Our recommendation is to use the path
App\Http\ViewComposerswhen creating any view composer as per the commentary.
Traits
- We have, by default, a number of useful traits that we call on in projects - automating Uuids when they're being used for IDs on models as well as the User ID for models requiring the authenticated user's ID when saving
- There's also a handy trait for determining whether a user has a particular role - the naming for this is up for debate as there may be other models beyond the
Userwho could possibly be assigned roles in the future
Config
- Default api driver has been updated from 'token' to 'passport' to reflect our dependancy on the Laravel Passport package
- Default Mailgun endpoint updated to point to the EU server
- Updated to use encrypted sessions and secure session cookies only
- This configuration means any dev work will have to see the website served using Laravel Valet with a secure TLS certificate in place. Running over HTTP will throw a 419 error.
- Updated any reference of the
Usermodel to beApp\Models\User
Database
- Updated migrations to reflect the changes on the
Usermodel - Migrations for the
Rolemodel and subsequent many-to-many relationship with ourApp\Models\Usermodel - Added a
UsersTableSeeder.phpand aRolesTableSeeder.phpto get things started - Removed the
UserFactor.phpfor the time being
Resources
- Default JS and SASS files have been updated to HGA standard configurations
- Overwrites the default layout structure from Laravel into something more 'us'
- Updates to the authentication scaffolding to account for the "first name" and "last name" options on the
Usermodel, but also to the styling because we don't use Bootstrap.- This update means you have no reason to run
php artisan make:auth
- This update means you have no reason to run
Routes
api.phphas been updated to prefix "v1" to the routes, which is good practice for software to account for when the API evolves over timeweb.phphas been updated to include Laravel'sAuth::routes()to handle authentication, whilst removing the stock routes created after runningphp artisan make:auth
Webpack
- By default, versioning is enabled
- Libraries such as VueJS and Axios are extracted to a
vendor.jsfile
Misc
- Includes Laravel Passport middleware for the
$webarray withinApp\Http\Kernel.php - Includes a custom validator
strong_passwordto ensure a weak password cannot be used when registering - Additional parameters have been appended to the end of the .env file, including:
- A Google Analytics param to hold the track ID, which will pre-populate the areas within the
layouts/app.blade.phpview - Mailgun parameters
- Mail parameters
- Session secure cookie (for ease of access in case Valet is unavailable to you)
- A Google Analytics param to hold the track ID, which will pre-populate the areas within the
- The package.json file has been updated to:
- Remove
- bootstrap
- lodash
- jquery
- popper.js
- Include
- fontawesome-free
- es6-promise
- sass
- sass-loader
- vue-template-compiler
- Remove
API Access
- Our preset ships with Laravel Passport to consume any API created via JavaScript (typically using a VueJS & Axios combination)
- By default, we ignore the Passport migrations because we're not requiring such functionality within our applications, but it's good to know it's there
- Turning these migrations back on is as simple as commenting out or removing the line
Passport::ignoreMigrations(), which is in theregister()method ofAppServiceProvider.php
- Turning these migrations back on is as simple as commenting out or removing the line