speedup egg search
This commit is contained in:
parent
96b231f7d9
commit
85d7015157
2 changed files with 35 additions and 1 deletions
|
|
@ -27,7 +27,7 @@ class EggController extends Controller
|
|||
$month = $date[1];
|
||||
|
||||
$moba = TraceaEgg::where('ede_code', '=', $code)
|
||||
->whereDate('dcr', Carbon::createFromDate(null, $month, $day)->toDate())
|
||||
->where('dcr', Carbon::createFromDate(null, $month, $day)->format('Y-m-d'))
|
||||
->orderBy('box_code', 'DESC')->first();
|
||||
|
||||
if (!$moba) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIndexesOnTracaEgg extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('tracea_eggs', function (Blueprint $table) {
|
||||
$table->index(['ede_code']);
|
||||
$table->index(['dcr']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('tracea_eggs', function (Blueprint $table) {
|
||||
$table->dropIndex(['ede_code']);
|
||||
$table->dropIndex(['dcr']);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue