buyersclub/laravel-eloquent-model-interface

此包已被弃用,不再维护。未建议替代包。

为缺失的 Laravel Eloquent 模型接口提供 Polyfill。

2.1.1 2021-08-08 13:05 UTC

This package is auto-updated.

Last update: 2024-04-08 18:59:09 UTC


README

Latest Stable Version License

模型接口

为缺失的 Laravel Eloquent 模型接口提供 Polyfill。

安装

composer require buyersclub/laravel-eloquent-model-interface

原因

如果您正在使用接口为您的模型,您可能有一些返回任意模型的方法,在这些情况下,能够使用反映该特性的类型提示会更方便。没有这个 Polyfill,只能通过类型提示 \Illuminate\Database\Eloquent\Model 来实现,这将与您的模型接口不完全兼容,通过引入这个基接口,您的模型接口可以扩展,从而解决这个问题。

这对于使用 PHPStan 或类似静态分析器尤其有用。

使用方法

use Buyersclub\Laravel\Eloquent\EloquentModelInterface;

interface UserInterface extends EloquentModelInterface
{
    //
}