<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Product;
use App\Attribute;
use App\Category;
use App\Models;
use App\City;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;

class FetchController extends Controller
{
    public function orderdatamodal(Request $request)
    {
        $category = Models::find($request->itemId);
        $category->update(['num'=>$request->itemPost]);
    }
    public function orderdata(Request $request)
    {
        $category = Category::find($request->itemId);
        $category->update(['num'=>$request->itemPost]);
    }
    public function modelscat($data){
        $models = Models::where('category_id',$data)->get();
         
         
         return view('admin.ajax.modelscat',compact('models'));
    }
    public function addchoise($data){
        return view('admin.ajax.addchoise',compact('data'));
    }
     public function attr($data){
         $rows = Attribute::where('category_id',$data)->get();
         
         
         return view('admin.ajax.attr',compact('rows'));
    }
    
    
    public function country($query){
         $rows = City::where('country_id',$query)->get();
       
        
        return view('admin.ajax.city',compact('rows'));
    }
     public function city($data){
        
         return view('admin.ajax.cities',compact('data'));
    }
    
    public function main($query){
        $rows = Models::where('category_id',$query)->get();
        
        
       return view('admin.ajax.models',compact('rows'));
    }
    public function model($query){
         $rows = Models::where('model_id',$query)->get();
        
        return view('admin.ajax.models',compact('rows'));
    }
    
    
}
