Download the PHP package wardenyarn/model-properties without Composer

On this page you can find all versions of the php package wardenyarn/model-properties. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package model-properties

Laravel Model Properties

Simple model properties implementation.

Problem

Imagine, you have a Page model with given schema

But then, you might decide to add a meta_title property. Or another bunch of properties, that might be useful for just one or two pages. In the end, we will see something like that:

Solution

To avoid extending of original table, we can use a one-to-one relation. But you will need to create additional table for every model with Properties. So, we might just use a polymorphic relation for properties and models.

This package is made to simplify this polymorphic relation setup.

Installation

You can install the package via composer:

Usage

First we need to publish a properties table and migrate it.

Second, we need to add HasProperties trait and fill protected $properties property.

And lastly, execute artisan properties:fill command, that will persist properties from model $properties into DB;

Access to properties

Just use $model->properties attribute to access to Properties object, that contains all the stuff.

Saving

Set properties values by $model->properties->property_name or using $model->properties->set() method.

It also works with new model instances:

Note: in this case only $model->save() method will save properties.

Cast

Property values will be automatically casted by Laravel.

Available casts:

If you need access to casted properties right after saving, you need to fresh() model before use.

Default values

You can define a default value for property

Caching

Property values are cached forever with first access to properties attribute, so the database load won't be an issue.

Cache will be refreshed with saving of properties or model.

You can always clear all of the Laravel cache by artisan command

Config

You can change config after importing it with given artisan command:

Testing

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.


All versions of model-properties with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wardenyarn/model-properties contains the following files

Loading the files please wait ....