Last active
June 29, 2020 21:21
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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