定制 combindma/mailcoach-skeleton 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

combindma/mailcoach-skeleton

最新稳定版本:2.2.0

Composer 安装命令:

composer require combindma/mailcoach-skeleton

包简介

A useful package to have user management in your mailcoach project

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.

统计信息

  • 总下载量: 352
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固