tobya/anymodel

允许创建任意表的 Laravel 实体模型

V1.7 2023-10-15 17:36 UTC

This package is auto-updated.

Last update: 2024-08-30 01:26:29 UTC


README

允许创建任意表或视图的 Laravel 实体模型

允许创建 Laravel 实体模型,无需首先声明模型。

这对于拥有使用视图的遗留应用程序且不希望为每个视图创建模型的情况特别有用。

    // return a new model built from vw_ConfirmedBookings table/view
    $Bookings =  AnyModel::table('vw_ConfirmedBookings')
                                  ->where('Confirmed',true)                                  
                                  ->orderBy('updated_at')
                                  ->get();

    // Work with model in normal way
    $Bookings->each(function($Booking){
        AddName( $Booking->name);
    });

安装

 composer require tobya/anymodel