kraenzle-ritter/resources

v0.0.7 2024-03-26 17:10 UTC

This package is auto-updated.

Last update: 2024-09-27 10:30:21 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License Tests

资源模型和hasResource特性,其中资源基本上是对资源(例如维基百科文章或GND条目)的链接。

安装

通过Composer

$ composer require kraenzle-ritter/resources

然后运行php artisan vendor:publish以发布迁移,或将文件复制到您的迁移目录。然后运行php artisan migrate

使用方法

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model
use KraenzleRitter\Resources\hasResources;

class MyModel extends Model
{
    use hasResources;

    ...

}

现在您已经准备好使用了

$resource = [
    'provider' => 'Wikipedia',
    'provider_id' => 4013996,
    'url' => 'https://fr.wikipedia.org/wiki/Érik_Desmazières'
    // optional 'full_json' => [...]
];

$model = MyModel::find(1);
$this->model->updateOrCreateResource($resource);
$model->resources;
...

使用artisan命令

php artisan resources:fetch --provider=gnd // or wikidata or wikipedia

您可以向已经具有gnd链接的模型添加更多资源。您可以在配置文件中配置资源列表。

许可证

许可证。请参阅许可证文件以获取更多信息。