PHP code example of iamkevinmckee / many-to-many

1. Go to this page and download the library: Download iamkevinmckee/many-to-many 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/ */

    

iamkevinmckee / many-to-many example snippets


public function up()
{
    Schema::create('post_tag', function (Blueprint $table) {
        $table->unsignedBigInteger('post_id');
        $table->unsignedBigInteger('tag_id');
        $table->foreign('post_id')->references('id')->on('posts')
            ->onDelete('cascade');
        $table->foreign('tag_id')->references('id')->on('tags')
            ->onDelete('cascade');
    });
}
 php
php artisan many-to-many FirstModel SecondModel
 php
php artisan many-to-many tag post