tobya/anymodel

Allows creation of a Laravel Entity Model for an arbitrary table

Installs: 3 553

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/tobya/anymodel

v1.8 2024-10-04 21:23 UTC

This package is auto-updated.

Last update: 2025-10-04 23:38:39 UTC


README

Allows creation of a Laravel Entity Model for an arbitrary table or view

Allow creation of Laravel Entity Model for any arbitrary table without needing to declare a Model first.

This is particuarily useful if you have a legacy application that uses Views and you do not wish to create a model for each view.

    // 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);
    });

Installation

 composer require tobya/anymodel