Database
Configuration
Maravel makes connecting with databases and running queries extremely simple. Currently Maravel supports four database systems: MySQL, PostgreSQL, SQLite, and SQL Server.
You may use the DB_* configuration options in your .env configuration file to configure your database settings, such as the driver, host, username, and password.
Basic Usage
Note: If you would like to use the
DBfacade, you should uncomment the$app->withFacades()call in yourbootstrap/app.phpfile.
For example, without facades enabled, you may access a database connection via the app helper:
$results = app('db')->select("SELECT * FROM users");
Or, with facades enabled, you may access the database connection via the DB facade:
$results = DB::select("SELECT * FROM users");
Basic Queries
To learn how to execute basic, raw SQL queries via the database component, you may consult the full Maravelith documentation.
Query Builder
Maravel may also utilize the Maravelith fluent query builder. To learn more about this feature, consult the full Maravelith documentation.
Eloquent ORM
If you would like to use the Eloquent ORM, you should uncomment the $app->withEloquent() call in your bootstrap/app.php file.
Of course, you may easily use the full Eloquent ORM with Maravel. To learn how to use Eloquent, check out the full Maravelith documentation.
Migrations
For further information on how to create database tables and run migrations, check out the Maravelith documentation on the migrations.