Cartalyst LLC.
Attributes by Cartalyst
3
14
0
5
1

This package requires a valid subscription. Subscribe for access.

Preface

Introduction

A Platform 9 extension to manage attributes across your application.

Have a read through the Installation Guide.

Features

  • create, update, delete attributes.
  • assign name & slug.
  • enabled/disable.
  • select namespace relation.
  • set description.
  • set type. input|radio|select|checkbox|textarea|multiselect
  • create and label options.
  • sort options.
  • blade call @attribute($entity) returns all attributes,
  • blade call @attribute($entity, 'slug') returns single attribute.
  • blade call @attribute($entity, [ 'slug', 'slug' ]) returns multiple attributes.

Examples

The $attributes variable used below is a reference to the AttributeRepository.

$attributes = app('platform.attributes');
Retrieve all attributes
$allAttributes = $attributes->findAll();
Dynamically create a new attribute.
$attributes->create([
    'name'    => 'Foo',
    'slug'    => 'foo',
    'type'    => 'input',
    'enabled' => true,
]);

Setup

Installation

The best and easiest way to install the Attributes extension is with Composer.

Preparation

Open your composer.json file and add the following to the require array:

"platform/attributes": "^8.0"

Add the following lines after the require array on your composer.json file:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.cartalyst.com"
    }
]

Note: Make sure that after the required changes your composer.json file is valid by running composer validate.

Install the dependencies

Run Composer to install or update the new requirement.

php composer install

or

php composer update

Now you are able to install the extension through Platform's admin.

Usage

In this section we'll show how you can manage your application's attributes.

Repository

IoC Binding

The attribute repository is bound to platform.attributes and can be resolved out of the IoC Container using that offset.

$attributes = app('platform.attributes');

Methods

The repository contains several methods that are used throughout the extension, most common methods are listed below.

For an exhaustive list of available methods, checkout the AttributeRepositoryInterface

  • findAll();

Returns a collection of all attributes.

  • find($id);

Returns a attribute object based on the given id.

  • findBySlug($slug);

Returns a attribute object based on the given slug.

  • forNamespace($namespace);

Returns a collection of attributes that are associated with the given namespace.

  • create(array $data);

Creates a new attribute.

  • update($id, array $data);

Updates an existing attribute.

  • delete($id);

Deletes a attribute.

  • enable($id);

Enables a attribute.

  • disable($id);

Disables a attribute.

You wont find fancy lifestyle graphics and marketing bravado here. Just cold... hard... code...

Code Well, Rock On!
Processing Payment...