| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
-
- namespace App\Http\Controllers\Api;
-
- use App\Http\Controllers\Controller;
- use App\Http\Requests\RegistEPaperRequest;
- use App\Models\Banner;
- use App\Models\EpaperSubscription;
- use App\Models\HomepageToTop;
- use App\Models\News;
- use App\Models\Setting;
- use App\Supports\Response;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
-
- /**
- * @group Lottery Prize
- */
- class HomePageController extends Controller
- {
- public function __construct(
- )
- {
- }
- public function banners($locale = 'tw')
- {
- $locale = $locale == "tw" ? "zh_TW" : $locale;
- $result = [];
- $banners = Banner::where("visible", true)->orderByDesc("order")->get()->map(function ($record) use (&$result, $locale){
- $result[] = [
- "imgUrl" => $record->imgUrlLink,
- "mobileImgUrl" => $record->mobileImgLink,
- "type" => $record->type,
- "title" => $record->getTranslation("title", $locale),
- "content" => $record->getTranslation("content", $locale),
- ];
- });
- return Response::ok($result);
- }
-
- public function list($locale = 'tw')
- {
- $locale = $locale == "tw" ? "zh_TW" : $locale;
- $result = [];
-
- $webNews = News::where("visible", 1)->orderByDesc("post_date")->limit(3)->get();
- foreach($webNews as $item){
- $result["list"][] = [
- "id" => $item->id,
- "categoryId" => $item->newsCategory->id,
- "category" => $item->newsCategory->getTranslation("name", $locale),
- "postDate" => Carbon::parse($item->post_date)->format("Y.m.d"),
- "title" => $item->getTranslation("title", $locale),
- ];
- }
- return Response::ok($result);
- }
- }
|