tadasei/laravel-statuses 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

tadasei/laravel-statuses

最新稳定版本:v2.1.0

Composer 安装命令:

composer require tadasei/laravel-statuses

包简介

A package that provides stubs for managing status associations with models

README 文档

README

This package provides stubs for statuses association to Eloquent models.

Features

  • Quickly generate statuses handling utilities.
  • Customize and extend generated code to fit your project's needs.
  • Improve development efficiency by eliminating repetitive tasks.

Installation

You can install the package via Composer by running:

composer require tadasei/laravel-statuses --dev

Publishing statuses handling utilities

To publish statuses handling utilities, use the following command:

php artisan statuses:install

Configuring Statusable Models

To extend or define which models are considered statusable:

  • Define a One-to-Many relationship with your model (one App\Models\Status has many App\Models\YourModel).
  • Add your model class name to the App\Enums\StatusableType enum.

This allows full flexibility in defining how your application links statuses to models.

Running migrations

To create the related statuses table, run the generated migration using the following command:

php artisan migrate

Register CRUD routes

This package generates a routes/resources/status.php route file among its utilities. You can include this file in your routes/web.php or routes/api.php to enable authenticated and authorized App\Models\Status model CRUD operations.

// in routes/api.php or routes/web.php
require __DIR__ . "/resources/status.php";

Usage:

The usage is the same as any regular One-to-Many relationship:

use App\Models\{Status, User};

$status = Status::create([
    "statusable_type" => User::class,
    "name" => "Initial status",
    "color" => "#858662",
    "is_initial" => true,
    "is_final" => false,
]);

$user = User::first();

$status->users()->save($user);

Customization

The generated code serves as a starting point. You can customize and extend it according to your project's requirements. Modify the generated utilities as needed.

Contributing

Contributions are welcome! If you have suggestions, bug reports, or feature requests, please open an issue on the GitHub repository.

License

This package is open-source software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-10