定制 awcodes/matinee 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

awcodes/matinee

最新稳定版本:v2.0.0

Composer 安装命令:

composer require awcodes/matinee

包简介

OEmbed field for Filament Panel and Form Builders.

README 文档

README

table repeater opengraph image

Latest Version on Packagist Total Downloads

Matinée

OEmbed and Video field for Filament Panel and Form Builders

Compatibility

Package Version Filament Version
1.x 3.x
2.x 4.x

Installation

You can install the package via composer:

composer require awcodes/matinee

Important

If you have not set up a custom theme and are using Filament Panels follow the instructions in the Filament Docs first.

After setting up a custom theme add the plugin's views to your theme css file or your app's css file if using the standalone packages.

@source '../../../../vendor/awcodes/matinee/resources/**/*.blade.php';

Preparing your model

Matinée stores its content as JSON data in a single column on your model. So, it is vital that you cast the column to an array or json object in your model.

protected $casts = [
    'video' => 'array', // or 'json'
];

Usage

use Awcodes\Matinee\Matinee;

Matinee::make('video')

Forcing the preview to show

use Awcodes\Matinee\Matinee;

Matinee::make('video')
    ->showPreview()

Custom Providers

Matinée comes with a Provider for YouTube and Vimeo, but you can add your own by creating a class and passing it into the providers modifier on the field.

use Awcodes\Matinee\Providers\Concerns\IsMatineeProvider;
use Awcodes\Matinee\Providers\Contracts\MatineeProvider;

class CustomProvider implements MatineeProvider
{
    use IsMatineeProvider;

    public function getId(): ?string
    {
        return 'custom';
    }

    public function getDomains(): array
    {
        return [
            'custom.com',
        ];
    }

    public function getOptions(): array
    {
        return [
            'controls' => 1,
            'title' => 0,
        ];
    }

    public function convertUrl(?array $options = []): string
    {
        return 'https://www.custom.com/embed/' . $this->getId() . '?' . http_build_query($options);
    }
}

Then you can use it by passing it into the providers modifier on the field instance or globally in the register method of a service provider with the configureUsing() method.

use Awcodes\Matinee\Matinee;

Matinee::make('video')
    ->providers([CustomProvider::class])

Rendering the video

You are free to render the video in any way you see fit, but Matinée comes with a blade component you can use for convenience.

<x-matinee::embed :data="$data" />

The stored data will take the following shape:

{
    "width": "16",
    "height": "9",
    "responsive": true,
    "url": "https:\/\/www.youtube.com\/watch?v=N9qZFD1NkhI",
    "embed_url": "https:\/\/www.youtube.com\/embed\/N9qZFD1NkhI?controls=1&start=0",
    "options": {
        "controls": "1",
        "nocookie": "0",
        "start": "00:00:00"
    }
}

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

  • 总下载量: 4.51k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 21
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 21
  • Watchers: 1
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-21