adideas/laravel-get-relationship-eloquent-model 问题修复 & 功能扩展

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

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

adideas/laravel-get-relationship-eloquent-model

Composer 安装命令:

composer require adideas/laravel-get-relationship-eloquent-model

包简介

Laravel get relationship eloquent models

README 文档

README

Имея одну или множество моделей Eloquent, благодоря этому пакету можно получить все ее отношения и их тип во время выполнения!

Иногда это действительно необходимо например для системы удалений где есть связи с другими сущностями. Например нужно удалить модель и динамически узнать что нужно еще удалить. Для этого вам не нужно знать названия методов в модели. И уж тем более подстраивать их названия не под архитектуру а под что то другое.

Этот пакет создан для других разработчиков, которым необходимо знать об отношениях.

Laravel как получить все отношения

как получить названия всех связей

getRelations()

--

Having one or many Eloquent models, thanks to this package, you can get all of its relationships and their type at runtime

Sometimes this is really necessary, for example, for a deletion system where there are connections with other entities. For example, you need to delete a model and dynamically find out what else needs to be deleted. You don't need to know the names of the methods in the model to do this. And even more so to adjust their names not for architecture, but for something else.

This package is for other developers who need to know about relationships.

View (get) all links (links) of any eloquent Laravel models

Installation

Require this package with composer using the following command:

composer require adideas/laravel-get-relationship-eloquent-model

Put star :) please

Usage

use App\Http\Controllers\Controller;
use Adideas\RelationFinder\Relations;

class MyController extends Controller
{



    public function show(MyModel $myModel, Relations $relations)
    {
        $relations->where('name', 'myRelationFunction'); // return collect

        dd($relations); // return collect

        Relations::relations($myModel)->where('name', 'myRelationFunction'); // return collect

    }



}

OR

use Adideas\RelationFinder\RelationsFinder;

class MyModel extends Model
{
    use RelationsFinder;

}
use App\Http\Controllers\Controller;

class MyController extends Controller
{



    public function show(MyModel $myModel)
    {
        MyModel::relations()->where('name', 'myRelationFunction'); // return collect
        
        // or

        $myModel->relations()->where('name', 'myRelationFunction'); // return collect
    }



}

Config

If you want to see all models! Install the key.

class MyModel extends Model
{
    const WITH_VENDOR_RELATION = true;
    
    // or

    public $withVendorRelation = true;
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-21