netflex/structure

This package is abandoned and no longer maintained. The author suggests using the netflex/structures package instead.

Netflex Structure library

v5.2.1 2024-11-20 13:10 UTC

This package is auto-updated.

Last update: 2024-11-21 09:47:29 UTC


README

Stable version Build status License: MIT Contributors Downloads

[READ ONLY] Subtree split of the Netflex Structures component (see netflex/framework)

Eloquent compatible model for working with Netflex structures.

Installation

composer require netflex/structure

Example usage

<?php

use Netflex\Structure\Model;

/**
 * @property string $permalink
 */
class Article extends Model
{
  /**
   * The directory_id associated with the model.
   *
   * @var int
   */
  protected $relationId = 10000;

  /**
   * The attributes that are mass assignable.
   *
   * @var array
   */
  protected $fillable = [
    'name', 'author', 'content'
  ];

  /**
   * Gets the full URL to the article
   *
   * @return string
   */
  public function getPermalinkAttribute()
  {
    return 'https://news.example.com/' . $this->created->format('Y-m-d') - '/' . $this->url;
  }
}

$articlesByJohn = Article::where('author', 'John Doe')
  ->paginate();

$slug = 'top-10-tricks-for-working-with-netflex';
$articleForUrl = Article::resolve($slug);

$firstArticle = Article::first();
$lastArticle = Article::last();

$newestArticle = Article::orderBy('updated', 'desc')->first();

$freshArticle = new Article([
  'name' => 'Fresh new article',
  'author' => 'John Doe',
  'content' => '<h1>Hello world!</h1>'
]);

$freshArticle->save();

Contributing

Thank you for considering contributing to the Netflex Structure! Please read the contribution guide.

Code of Conduct

In order to ensure that the community is welcoming to all, please review and abide by the Code of Conduct.

License

Netflex Structure is open-sourced software licensed under the MIT license.

Copyright © 2020 Apility AS