routes:
In laravel routes are seen in routes/web.php file
Route::get('/', function () {
return view('welcome');
});requests:
According to the official website MongoDB is a document database that provides high performance, high availability, and easy scalability.
MongoDB falls into the group of documents-oriented NoSQL databases
steps to use mangodb with php:
extension=php_mongo.dllcomposer require mongodb/mongodbArray_filter() :
<?php
class Post
{
public $title;
public $published;
public function __construct($title, $published){
$this->title = $title;Connection.php
<?php
class Connection<?php
try {
$pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '');
}catch( PDOException $e ){
die("couldn't connect ".$e->getMessage());//gives error message
}
$statement = $pdo->prepare('select * from todos');| <?php | |
| $host = 'localhost'; | |
| $user = 'root'; | |
| $password = '123456'; | |
| $dbname = 'pdoposts'; | |
| // Set DSN | |
| $dsn = 'mysql:host='. $host .';dbname='. $dbname; | |
| // Create a PDO instance |
one to one :
user can have profile or address
user has one profile:
add this in user model as:
public function profile()
{
return $this->hasOne(Profile::class);
}check the following links for the useful packages in Laravel:
https://www.cloudways.com/blog/best-laravel-packages/