netflex/structures

Netflex 结构库

v5.0.2 2024-08-16 15:57 UTC

This package is auto-updated.

Last update: 2024-09-16 16:08:49 UTC


README

Stable version Build status License: MIT Contributors Downloads

[只读] Netflex Structures 组件的子树拆分(见 netflex/framework

适用于与 Netflex 结构一起工作的 Eloquent 兼容模型。

安装

composer require netflex/structure

示例用法

<?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();

贡献

感谢您考虑为 Netflex Structure 做贡献!请阅读贡献指南

行为准则

为了确保社区对所有成员都友好,请阅读并遵守行为准则

许可证

Netflex Structure 是在MIT 许可证下开源的软件。

版权所有 © 2020 Apility AS