plank/larelations 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

plank/larelations

最新稳定版本:1.0.0

Composer 安装命令:

composer require plank/larelations

包简介

Extract the relations from a given Laravel model

README 文档

README

Laravel Version Support GitHub Workflow Status Code Climate coverage Code Climate maintainability

This package is designed to extract Eloquent Relations from a given Model using reflection and return type checking.

Installation

You can install the package via composer:

composer require plank/larelations

Usage

Given an instance of an Eloquent Model or its class-string, this package will extract all relations defined on the model, and return them in a Collection of RelationInstance items.

Each RelationInstance has the ReflectionMethod ($method) where the relation was defined, as well as an instance of the Relation ($relation). There are some helper methods on the RelationInstance that allow you to classify the type relation it is (ie. child, parent, pivotted, etc).

$extractor = new \Plank\Larelations\Extractor();
$instances = $extractor->extract($post);
$instances = \Plank\Larelations\Facades\Larelations::extract(Post::class);

foreach ($instances as $instance) {
    if ($instance->isChild()) {
        // Handle child types of relations
    }

    if ($instance->relation instanceof \Znck\Eloquent\Traits\BelongsToThrough) {
        // Handle custom relation
    }

    // The method property is the \ReflectionMethod of the relation instance
    $instance->method->getName(); // posts
}

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

Security Vulnerabilities

If you discover a security vulnerability within Larelations, please send an e-mail to security@plankdesign.com. All security vulnerabilities will be promptly addressed.

统计信息

  • 总下载量: 35
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固