Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mkwsra/074073428baa457d755f6d3911485b71 to your computer and use it in GitHub Desktop.
Save mkwsra/074073428baa457d755f6d3911485b71 to your computer and use it in GitHub Desktop.
How to implement dynamic slug in Laravel 7? Medium.com alike post links
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePostsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
// ADD THE FOLLOWING LINE ONLY
$table->char('uuid', 10)->unique();
// ... other table columns
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('posts');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment