anekdotes/staticmodel

Abstract class used to create static Model classes. These classes have their data initiated in themselves. Allows Model operations to be used to a certain extent.

2.0.0 2021-11-24 15:45 UTC

This package is auto-updated.

Last update: 2024-12-24 22:21:34 UTC


README

Latest Stable Version Build Status codecov.io StyleCI License Total Downloads Codacy Badge

Abstract class used to create static Model classes. These classes have their data initiated in themselves. Allows Model operations to be used to a certain extent.

Installation

Install via composer into your project:

composer require anekdotes/staticmodel

Usage

Create your static class by inheriting StaticModel. Fill it with your static data.

class Languages extends StaticModel {

  public static $data = array(
    array(                 
      'id' => 1,           
      'name' => 'English',
      'small' => 'en' 
    )
  );
      
}       

You can then call the model as any other Illuminate model, and use most of Illuminate's functionalities.

$english = Languages::find(1);
$englishname = $english->name;