<?php

namespace App\Http\Controllers;

use App\Http\Services\RoleService;
use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierService;
use App\Http\Services\ViewCheckService;
use App\Model\IntracodeModel;
use App\Model\SupplierApplyModel;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class SupplierApplyController extends Controller
{
    public function info(Request $request, $id = '')
    {
        if ($request->path() == '/') {
            $path = 'web/index';
        } else {
            $path = $request->path();
        }
        $this->data = [
            'menus' => $request->menus,
            'header' => $request->user->header,
            'username' => $request->user->email,
            'user_email' => $request->user->email,
            'uri' => '/' . $path,
            'id' => $id
        ];
        return $this->$id($request);
    }

    public function __call($name, $arr)
    {
        $data['errinfo'] = '访问路径错误';
        return view('errors.error', $data);
    }


    //操作日志列表
    public function SupplierApplyList($request)
    {
        $this->data['auditUidList'] = SupplierApplyModel::pluck('audit_name', 'audit_uid')->toArray();
        $this->data['title'] = '供应商账号列表';
        return $this->view('供应商账号列表');
    }

    public function AuditSupplierApply($request)
    {
        $id = $request->get('id');
        $apply =  SupplierApplyModel::with('supplier')->where('id', $id)->first()->toArray();
        $apply['supplier_group_name'] = array_get(config('fixed.SupplierGroup'), $apply['supplier']['supplier_group']);
        $this->data['apply'] = $apply;
        $this->data['title'] = '芯链入驻审核';
        return $this->view('芯链入驻审核');
    }
}