最新周稻虾价格

dev
李静 2023-05-17 10:05:48 +08:00
parent 666cd6fa88
commit 03f8cf9c39
1 changed files with 13 additions and 0 deletions

View File

@ -10,6 +10,7 @@ use App\Models\RiceShrimpPrice;
use App\Models\RiceShrimpWeeklyPrice;
use Peidikeji\Keywords\Models\Keywords;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ChartController extends Controller
{
@ -99,7 +100,19 @@ class ChartController extends Controller
];
});
$keywordsTable = (new Keywords())->getTable();
$riceShrimpWeeklyPricesTable = (new RiceShrimpWeeklyPrice)->getTable();
$latestPrice = RiceShrimpWeeklyPrice::query()
->join($keywordsTable, fn ($join) => $join->on("$riceShrimpWeeklyPricesTable.week", '=', "$keywordsTable.id"))
->where("$keywordsTable.type_key", 'weeks-per-year')
->latest("$riceShrimpWeeklyPricesTable.year")
->latest(DB::raw("$keywordsTable.key::INTEGER"))
->value("$riceShrimpWeeklyPricesTable.price");
return [
'c_price' => $latestPrice,
'c_week' => ($now->month - 1) * 4 + ($now->weekOfMonth > 4 ? 4 : $now->weekOfMonth),
'x_axis' => $weeks->values(),
'series' => $series->sortKeys()->values()->all(),