PHP code example of leroy-merlin-br / mongolid-laravel

1. Go to this page and download the library: Download leroy-merlin-br/mongolid-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

leroy-merlin-br / mongolid-laravel example snippets


'providers' => [
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,
    ...
    MongolidLaravel\MongolidServiceProvider::class,
],

'aliases' => [
    'App'         => Illuminate\Support\Facades\App::class,
    'Artisan'     => Illuminate\Support\Facades\Artisan::class,
    ...
    'MongoLid'    => MongolidLaravel\MongoLidModel::class,
],

/*
|--------------------------------------------------------------------------
| MongoDB Databases
|--------------------------------------------------------------------------
|
| MongoDB is a document database with the scalability and flexibility
| that you want with the querying and indexing that you need.
| Mongolid Laravel use this config to starting querying right now.
|
*/

'mongodb' => [
    'default' => [
        'host'     => env('DB_HOST', '127.0.0.1'),
        'port'     => env('DB_PORT_NUMBER', 27017),
        'database' => env('DB_DATABASE', 'my_database'),
        'username' => env('DB_USERNAME', null),
        'password' => env('DB_PASSWORD', null),
    ],
],

'mongodb' => [
    'default' => [
        'cluster' => [
            'replica_set' => env('DB_REPLICA_SET', null),
            'nodes' => [
                'primary' => [
                    'host' => env('DB_HOST_A', 'host-a'),
                    'port' => env('DB_PORT_A', 27017),
                ],
                'secondary' => [
                    'host' => env('DB_HOST_B', 'host-b'),
                    'port' => env('DB_PORT_B', 27017),
                ],
            ],
        ],
        'database' => env('DB_DATABASE', 'mongolid'),
        'username' => env('DB_USERNAME', null),
        'password' => env('DB_PASSWORD', null),
    ],
],

'mongodb' => [
    'default' => [
        'connection_string' => 'mongodb://host-a:27017,host-b:27917/mongolid?replicaSet=rs-ds123',
    ],
],


namespace App;

use MongolidLaravel\MongolidModel;

class User extends MongolidModel
{

}


    'providers' => [

        // ...

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

        // ...

    ],



namespace App;

use Illuminate\Contracts\Auth\Authenticatable;
use MongolidLaravel\MongolidModel;

class User extends MongolidModel implements Authenticatable
{
    /**
     * The database collection used by the model.
     *
     * @var string
     */
    protected $collection = 'users';

    /**
     * Get the name of the unique identifier for the user.
     *
     * @return string
     */
    public function getAuthIdentifierName()
    {
        return '_id';
    }

    /**
     * Get the unique identifier for the user.
     *
     * @return mixed
     */
    public function getAuthIdentifier()
    {
        return $this->_id;
    }

    /**
     * Get the password for the user.
     *
     * @return string
     */
    public function getAuthPassword()
    {
        return $this->password;
    }

    /**
     * Get the token value for the "remember me" session.
     *
     * @return string
     */
    public function getRememberToken()
    {
        return $this->remember_token;
    }


    /**
     * Set the token value for the "remember me" session.
     *
     * @param  string  $value
     */
    public function setRememberToken($value)
    {
        $this->remember_token = $value;
    }

    /**
     * Get the column name for the "remember me" token.
     *
     * @return string
     */
    public function getRememberTokenName()
    {
        return 'remember_token';
    }
}

    'failed' => [
        'database' => 'mongodb',
        'collection' => 'failed_jobs',
    ],