PHP code example of combindma / mailcoach-skeleton
1. Go to this page and download the library: Download combindma/mailcoach-skeleton library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
combindma / mailcoach-skeleton example snippets
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;
}
}
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');
}