Return to Snippet

Revision: 65612
at December 31, 2013 05:42 by CreativePunch


Initial Code
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreatePostsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('posts', function(Blueprint $table) {
			$table->engine = 'MyISAM'; // means you can't use foreign key constraints
			$table->increments('id');
			$table->string('title');
			$table->text('body');
			$table->timestamps();
		});

		DB::statement('ALTER TABLE posts ADD FULLTEXT search(title, body)');
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::table('posts', function($table) {
	    	$table->dropIndex('search');
		});
		Schema::drop('posts');
	}

}

Initial URL
http://creative-punch.net/implementing-laravel-4-full-text-search/

Initial Description
In this tutorial I will go over implementing Full-Text search in Laravel 4 .
Those who have used Laravel 3 in the past may remember that there used to be support for FULLTEXT indexes. This functionality has been removed in Laravel 4 but can still easily be implemented.

Initial Title
Implementing Full-Text search in Laravel 4

Initial Tags
mysql, php

Initial Language
PHP