承接 appiersign/realtime-model 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

appiersign/realtime-model

最新稳定版本:v1.0.4

Composer 安装命令:

composer require appiersign/realtime-model

包简介

This package enables syncing laravel models with Google Firestore

README 文档

README

This package enables you to sync laravel models with Google Cloud Firestore. This packages works with an internally developed API that uses the gprc PHP extension to seamlessly connect your PHP backend to Firestore.

Installation

composer require appiersign/realtime-model

Set Up

Set these params in your .env file:

    ...
    FIRESTORE_SERVER_URI=
    API_GATEWAY_TOKEN=
    ...

Configuration

Add the realtime model service provider 'providers' array in your config/app.php file.

[
...
AppierSign\RealtimeModel\Providers\RealtimeModelServiceProvider::class

]

Add "AppierSign\\RealtimeModel\\": "vendor/appiersign/realtime-model/src" to the autoload.psr-4 object in your composer.json file

Usage

To automatically sync data to firestore, just add the RealtimeModel trait to the desired model. This will automatically sync all model attributes to Firestore whenever a new model is created or updated.

You can also use the realtime artisan command to sync all data associated with a model:

    php artisan realtime:sync User

To define which fields or attributes to sync, define the toRealtimeData() public method on the model like this:

public function toRealtimeData(): array
{
    return [
        'externalId' => $this->external_id,
        'fullName' => $this->full_name,
        'phone' => $this->phone,
        'username' => $this->username
    ];
}

Setting Key

To set the id or primary/unique key for the model, override the getSyncKey() public method on the model like this:

public function getSyncKey(): string
{
    return 'externalId';
}

The package uses the plural form of the model name as the suffix of the collection name to change this, override the collection() public method on the model like this:

public function collection(): string
{
    return 'premium_users';
}

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固