<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
peltonsolutions / laravel-pivot-table-helper example snippets
use App\Models\User;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use PeltonSolutions\LaravelPivotTableHelper\Models\GenerateBelongsToManyMigration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
GenerateBelongsToManyMigration::createMigration(
(new User())->roles()
);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists((new User())->roles()->getTable());
}
};
use App\Models\User;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use PeltonSolutions\LaravelPivotTableHelper\Models\GenerateBelongsToManyMigration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
$instance = new User();
GenerateBelongsToManyMigration::createMigration([
$instance->relationship1(),
$instance->relationship2(),
]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists((new User())->roles()->getTable());
}
};
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.