<?php

namespace App\Http\Controllers\Web;

use App\Models\Attribute;
use App\Models\AttributeChoice;
use App\Models\Choice;
use App\Models\ChoiceAttribute;
use App\Models\City;
use App\Models\Page;
use App\Models\Partner;
use App\Models\ProductAttribute;
use App\Models\Rate;
use App\Models\Slider;
use App\Http\Requests\Web\RateRequest;
use App\Models\Review;
use App\Services\Auth\User\AccountService;
use App\Services\Response\ResponseService;
use Illuminate\Http\Request;
use Illuminate\View\View;
use App\Http\Controllers\Controller;

class RateController extends Controller
{


    public function rating(RateRequest $request,$id)
    {
        $user = (new AccountService())->getAccount();

        $status = $user['status'];
        $user = $user['user'];
        Rate::create([
            'status'=>$status,
            'user_id'=>$user->id,
            'rate'=>$request->rate,
            'comment'=>$request->comment,
            'image'=>$status == 'visitor' ? 'user.jpg' : $user->photo,
            'name'=>$user->role == 'company' ? $user->descriptions()->name :$user->name,
            'product_id'=>$id,
        ]);
        $response =
            [
                'status' => 200,
                'message' => __('web.success'),
                'data'=>url()->previous(),
            ];
        return ResponseService::response($response);
    }



}
