PHP code example of rework-devs / mongolid-laravel
1. Go to this page and download the library: Download rework-devs/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/ */
/*
|--------------------------------------------------------------------------
| 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),
],
],
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';
}
}