定制 allenjd3/mongo-entries 二次开发

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

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

allenjd3/mongo-entries

Composer 安装命令:

composer require allenjd3/mongo-entries

包简介

An example package that allows you to store Statamic entries in a database.

README 文档

README

Installation

composer require allenjd3/mongo-entries --with-all-dependencies

Set up you database connection in config/database.php.

'connections' => [
    'mongodb' => [
        'driver' => 'mongodb',
        'dsn' => env('DB_DSN'),
        'database' => env('DB_DATABASE'),
    ],
],

Add the following to your .env file.

DB_CONNECTION=mongodb
DB_DSN=mongodb://

Usage

Start by creating a new Statamic site. If you are planning to use mongodb to store users, you can skip creating a user.

statamic new my-site

If you'd like to use authentication, you will need to change some config values.

First register MongoAuthServiceProvider in config/app.php.

'providers' => [
    // ...
    \Allenjd3\Mongo\Providers\MongoAuthServiceProvider::class,
],

Then change the repository config in config/statamic/users.php.

'repository' => 'mongo',
'repositories' => [
    'mongo' => [
        'driver' => 'mongo',
    ],
],

Add the following to the providers array in config/auth.php.

        'users' => [
            'driver' => 'mongo',
            'model' => App\Models\User::class,
        ],

Then in your App\Model\User class, you will need to extend the Allenjd3\Mongo\Auth\User class as authenticatable

use Allenjd3\Mongo\Auth\User as Authenticatable;

and use the following trait-

//other traits
use HasUuids;

Cast the following in your App\Model\User class-

    protected $casts = [
        'preferences' => 'json',
        'super' => 'boolean',
    ];

    protected $dates = [
        'created_at',
        'updated_at',
        'email_verified_at',
    ];

Create a new user

php please make:user

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-11-29