<?php

namespace App\Http\Controllers\API\Admin\YeWu;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class NavController extends Controller
{
    public function GetList()
    {
        $page = request('page');
        $pageSize = request('pageSize');
        $searchInfo = request('searchInfo');
        $list=DB::table('web_nav')->where(['is_del'=>0]);
        $count=$list->count();
        $list=$list
            ->skip(($page-1)*$pageSize) // 跳过前9999条记录
            ->take($pageSize)->get();

        return \Yz::Return(true,"查询完成",['list'=>$list,'count'=>$count]);
    }
    public function Save()
    {
        $Info = request('Info');
        $data=[
            'title'=>$Info['title'],
            'l_title'=>$Info['l_title'],
            'url'=>$Info['url']
        ];
        if($Info['id']==0){
            $u=DB::table('web_nav')->insert($data);
        }else{
            $u=DB::table('web_nav')->where(['id'=>$Info['id']])->update($data);
        }

        if($u){
            return \Yz::Return(true,"操作完成",[]);
        }else{
            return \Yz::echoError1("没有数据更新");
        }
    }
    public function Del()
    {
        $id = request('id');
       $d= DB::table('web_nav')->where(['id'=>$id])->update([
            'is_del'=>1
        ]);
        if($d){
            return \Yz::Return(true,"操作完成",[]);
        }else{
            return \Yz::echoError1("删除失败");
        }
    }
}
