-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from yocmen/yocmen/modify-import-query
Feature: Add the makeAllSearchableUsing API to the default import source
- Loading branch information
Showing
6 changed files
with
115 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Laravel\Scout\Searchable; | ||
|
||
class Post extends Model | ||
{ | ||
use Searchable; | ||
|
||
protected function makeAllSearchableUsing($query) | ||
{ | ||
return $query->where('status', 'published'); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use App\Post; | ||
use Faker\Generator as Faker; | ||
|
||
$factory->define(Post::class, function (Faker $faker) { | ||
return [ | ||
'title' => $faker->text, | ||
'body' => $faker->text, | ||
'status' => 'draft', | ||
'date' => $faker->date(), | ||
]; | ||
}); | ||
|
||
$factory->state(Post::class, 'draft', function () { | ||
return [ | ||
'status' => 'draft', | ||
]; | ||
}); | ||
|
||
$factory->state(Post::class, 'published', function () { | ||
return [ | ||
'status' => 'published', | ||
]; | ||
}); |
28 changes: 28 additions & 0 deletions
28
tests/laravel/database/migrations/2019_15_02_000002_create_post_table.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
final class CreatePostTable extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::create('posts', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('title'); | ||
$table->string('body'); | ||
$table->string('status'); | ||
$table->dateTime('date'); | ||
$table->softDeletes(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('posts'); | ||
} | ||
} |