<?php

namespace App\Service;
use DB;
use App\Models\User;

class UploadService
{
    public function uploadfile($request){
        if($request->file()) {
            
        	// $file = $request->file('file');
        	// $filename = time().'_'.$request->file->getClientOriginalName();
        	// $destinationPath = 'uploads';
        	// $file->move($destinationPath.'/', $filename);
        	
        	// $user['imageurl'] = $destinationPath.'/'. $filename;
            $photo = $request->file('file');
            $filename = time() . '.' . $photo->getClientOriginalExtension();
            $path = public_path('uploads');
            $photo->move($path, $filename);
            $quotation->file = $filename;
            return $filename;
        }
   }
    public function uploadbanner($request,$banner){
        // $user=User::where('id',$request['id'])->first();
        if($request->file()) {

            $file = $request->file('file');
            $filename = time().'_'.$request->file->getClientOriginalName();
            $destinationPath = 'banners';
            $file->move($destinationPath.'/', $filename);
            
            $banner['fullurl'] = $destinationPath.'/'. $filename;
            $banner->update();
            return $banner;
        }
    }
    public function uploadicon($request,$banner){
        // $user=User::where('id',$request['id'])->first();
        if($request->file()) {

            $file = $request->file('file');
            $filename = time().'_'.$request->file->getClientOriginalName();
            $destinationPath = 'icon';
            $file->move($destinationPath.'/', $filename);
            
            $banner['icon'] = $destinationPath.'/'. $filename;
            $banner->update();
            return $banner;
        }
    }
}