1. Go to this page and download the library: Download stolentine/macros 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/ */
stolentine / macros example snippets
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
Schema::table('', function (Blueprint $table) {
$table->createType('claim_document_types')
->enum(['contract', 'act', 'ttn', 'check']);
});
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
Schema::table('', function (Blueprint $table) {
$table->dropType('claim_document_types')->ifExists();
});
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
Schema::create('claim_documents', function (Blueprint $table) {
$table->addColumnRaw('claim_document_types', 'type');
});
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
Schema::create('table', function (Blueprint $table) {
$table->customUnique('column');
$table->customUnique('column', 'index_name');
$table->customUnique(['column1', 'column2']);
$table->customUnique(['column1', 'column2'], 'index_name');
$table->customUnique('inn')
->where('deleted_at', 'is', null)
->where('create_at', 'is', null, 'or');
$table->customUnique('inn')
->whereIsNull('create_at');
// только для deleted_at
$table->customUnique('inn')
->whereDeletedAtIsNull();
});
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
Schema::create('table', function (Blueprint $table) {
$table->customDropIndex('index_name')->ifExists();
$table->customDropIndex(['column'])->ifExists();
$table->customDropIndex(['column1', 'column2'])->ifExists();
});
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Query\Builder;
Schema::table('table', function (Blueprint $table) {
$table->addConstraint(['amount'])->check('amount >= 0 OR amount IS NULL');
$table->addConstraint('table_not_negative_amount_check')->check('amount >= 0 OR amount IS NULL');
$table->addConstraint(['amount'])->check(fn (Builder $q) => $q
->where(fn (Builder $q) => $q
->where('amount', '>=', 0)
->orWhereNull('amount')
)
);
});
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
Schema::table('table', function (Blueprint $table) {
$table->dropConstraint(['amount']);
$table->dropConstraint('table_not_negative_amount_check');
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.