A package to make your database more powerful.
Install via composer:
composer require alvarofpp/expand-database
Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
But if you don't use auto-discovery, open the config/app.php
file and add the following line to register the service provider:
'providers' => [
// ...
Alvarofpp\ExpandDatabase\ExpandDatabaseServiceProvider::class,
// ...
],
This package currently contains:
- Table comment (MySQL/PostgreSQL).
- To Sql with bindings.
Add a comment to a table (MySQL/PostgreSQL).
Use the method comment
in your Blueprint object, like:
<?php
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
$table->comment('Stores users');
});
To remove the table comment, use removeComment()
method:
<?php
Schema::table('users', function (Blueprint $table) {
$table->removeComment();
});
You can use the toSqlWithBindings()
method to print your SQL with bindings (obviously). See this example:
<?php
$query = Course::where('price', '>', $request->price)
->where('rating', '>=', $request->min_rating)
->where('rating', '<=', $request->max_rating);
dd($query->toSql(), $query->toSqlWithBindings());
// toSql(): "select * from "courses" where "price" > ? and "rating" >= ? and "rating" <= ?"
// toSqlWithBindings(): "select * from "courses" where "price" > 100.0 and "rating" >= 4.3 and "rating" <= 5.0"
Contributions are more than welcome. Fork, improve and make a pull request. For bugs, ideas for improvement or other, please create an issue.