combindma / mailcoach-skeleton
A useful package to have user management in your mailcoach project
Requires
- php: ^8.3
- filament/actions: ^3.2
- filament/forms: ^3.2
- illuminate/contracts: ^11.0|^12.0
- laravel/sanctum: ^3.3|^4.0
- laravel/ui: ^4.6.1
- livewire/livewire: ^3.4
- spatie/laravel-package-tools: ^1.14.0
- spatie/laravel-welcome-notification: ^2.4
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0|^9.0
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
About Combind Agency
Combine Agency is a leading web development agency specializing in building innovative and high-performance web applications using modern technologies. Our experienced team of developers, designers, and project managers is dedicated to providing top-notch services tailored to the unique needs of our clients.
If you need assistance with your next project or would like to discuss a custom solution, please feel free to contact us or visit our website for more information about our services. Let's build something amazing together!
Getting Started
Before you begin, make sure you have the Mailcoach package installed and configured in your new Laravel project. You can find the installation instructions here.
Installation
You can install the package via composer:
composer require combindma/mailcoach-skeleton
Update the User model to this:
namespace App\Models; use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; use Laravel\Sanctum\PersonalAccessToken; use Spatie\Mailcoach\Domain\Settings\Models\MailcoachUser; use Spatie\Mailcoach\Domain\Shared\Traits\UsesMailcoachModels; use Spatie\WelcomeNotification\ReceivesWelcomeNotification; class User extends Authenticatable implements MailcoachUser { use HasApiTokens; use Notifiable; use ReceivesWelcomeNotification; use UsesMailcoachModels; protected $fillable = [ 'name', 'email', 'password', ]; protected $hidden = [ 'password', 'remember_token', ]; protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } public function personalAccessTokens(): MorphMany { return $this->morphMany(PersonalAccessToken::class, 'tokenable'); } public function canViewMailcoach(): bool { return true; } }
Add this to your file app/providers/AppServiceProvider.php:
use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Combindma\MailcoachSkeleton\Listeners\SetupMailcoach; use Spatie\Mailcoach\Domain\Shared\Events\ServingMailcoach; public function boot(): void { Event::listen( Registered::class, SendEmailVerificationNotification::class, ); Event::listen( ServingMailcoach::class, SetupMailcoach::class, ); RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); }); Route::mailcoach('/app'); }
You must register the routes needed. Add this in your web file:
MailcoachSkeleton::routes('app');
Add these middlewares to boostrap/app:
->withMiddleware(function (Middleware $middleware) { $middleware->redirectGuestsTo(fn () => route('login')); $middleware->redirectUsersTo('/dashboard'); $middleware->throttleApi(); })
You can publish and run Laravel default migrations ('create_users_table', 'create_sessions_table', 'create_password_resets_table', 'create_jobs_table', 'create_failed_jobs_table') with:
php artisan vendor:publish --tag="mailcoach-skeleton-migrations"
php artisan migrate
Optionally, you can publish the views using
php artisan vendor:publish --tag="mailcoach-skeleton-views"
Creating the first user
After that you can create an initial user by executing php artisan mailcoach:make-user
. You can use the created user to login at Mailcoach. New user can be made on the users screen in mailcoach.
Registering custom action: wait for a date
You can register our custom action by adding the classname to the mailcoach.automation.flows.actions config key.
[ 'actions' => AutomationAction::defaultActions()->merge([ \Combindma\MailcoachSkeleton\Actions\WaitForDateAction::class, ])->toArray(), ]
Credits
License
The MIT License (MIT). Please see License File for more information.