<?php

namespace App\Http\Controllers\V1;

use App\Models\Banner;
use App\Models\Contact;
use App\Models\ProductHot;
use App\Models\User;
use Cache;
use EasyWeChat\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Laravel\Socialite\Facades\Socialite;
use PHPUnit\Util\Exception;
use Validator;

class SettingController extends Controller
{
    public function loginBanner(): JsonResponse
    {
        $lists = Banner::select(['name','image'])
            ->where('is_opened' ,1)
            ->orderByDesc('sort')
            ->get();
        return $this->success($lists);
    }


    public function contact(): JsonResponse
    {
        $lists = Contact::select(['name','phone_num','wechat_num'])->get();

        return $this->success($lists);
    }

    public function indexBanner(): JsonResponse
    {
        $type = \user()->account->type != 1 ? 2 : 1;
        $lists = ProductHot::select(['cover_img as image','product_id'])
            ->where('type',$type)
            ->where('is_opened' ,1)
            ->orderByDesc('sort')
            ->get();

        return $this->success($lists);
    }
}
