<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use \App\Rules\Count;
use DB;
class ServiceController extends Controller
{
    public function __construct()
    {
        $this->middleware(function ($request, $next) {
            if(auth()->check()){

                //SET PERMISSION WHO CAN VISIT THIS CONTROLLER
                $allow = ['admin', 'member', 'reseller', 'priority'];

                $level = auth()->user()->level;
                if(!in_array($level, $allow)){
                    abort(505);
                }
            }
            else{
                return redirect('/login');
            }
            return $next($request);
        });
    }
    
    public function comment()
    {
        return view('server.comments');
    }
    
    public function story()
    {
        return view('server.story');
    }
    
    public function storys()
    {
        return view('server.storys');
    }
    
    public function live()
    {
        return view('server.liveviews');
    }
    
    public function likecomment()
    {
        return view('server.likecomment');
    }
    
        public function dataC()
    {
        $level = auth()->user()->level;

        
        if(\Auth::User()->username == 'Demo'){
            $pesan = 'SUKSES';
            session()->flash('result', $pesan);
            return back();
        }
        
        $key = "00df632e94340a29e4f0bc062cea93af";

    //     $delay = 10;
        
    
    // $as = explode("\n", request()->comment);
// 	$c = curl_init('https://api.instagram.com/oembed/?url='.trim(request()->url));
//         curl_setopt($c,CURLOPT_RETURNTRANSFER,1);
//         curl_setopt($c,CURLOPT_SSL_VERIFYPEER,0);
//         curl_setopt($c,CURLOPT_USERAGENT,"SEBASTIANW-PC 11/23.01.78.64 Recognized as Mozilla(AppleWebKit SPA)");
//         $x = curl_exec($c);
//         $xinfo = curl_getinfo($c);
//         curl_close($c);
        
//         if ($xinfo['http_code'] !== 200) {
//             $mediaid = null;
//         } else {
//             $mediaid = json_decode($x);
//             $mediaid = $mediaid->media_id;
//             $mediaid = explode("_", $mediaid);
//             $mediaid = $mediaid[0];
//         }
        
        
    	
//     	$id_media =  $mediaid;
//     	$jumlah = request()->comment;

// 		$ch=curl_init("https://panel-fp.com/ApiPrivate/koment.php?mediaid=$id_media&token=IVmedia.fp");
// 		curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
// 		curl_setopt($ch,CURLOPT_POST,1);
// 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
// 		curl_setopt($ch,CURLOPT_POST,TRUE);
// 		curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);
// 		curl_setopt($ch,CURLOPT_POSTFIELDS,"comment=$jumlah");
// 		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);		
// 		curl_setopt($ch,CURLOPT_USERAGENT,"Haqny-PC 11/23.01.78.64 Recognized as Mozilla(AppleWebKit SPA)");
// 		curl_setopt($ch,CURLOPT_TIMEOUT,3);
// 		$result = curl_exec($ch);
// 		curl_close($ch);
		
		
		
// 		$history = new \App\History;
//         $history->submitted_by = auth()->user()->username;
//         $history->target = request()->url;
//         $history->type = 'comment';
//         $history->total_submit = count(explode(PHP_EOL, request()->comment));
//         $history->ip = $_SERVER['REMOTE_ADDR'];
//         $history->save();


//         $urlServer = 'http://209.97.129.35/bowoluvifan.php?urlxx='.request()->url.'&komeng='.request()->comment;
//         $ca = curl_init();
//         curl_setopt($ca, CURLOPT_URL, $urlServer);
//         curl_setopt($ca, CURLOPT_RETURNTRANSFER, 1);
        

//         curl_setopt($ca,CURLOPT_TIMEOUT, 5);
        
//         $za = curl_exec($ca);
//         curl_close($ca);

    //     $username = "ivan";
    // 	$password = "sabargblkz123";
    // 	$links = request()->url;
    // 	$jums = request()->comment;
    	
        // $result = $this->proses("http://167.99.202.150/panel/","urlnyax={$links}&commentar={$jums}",$username,$password);
        
        // $login = $this->curl('http://209.97.179.175/panel/masuk/userlogin.php','username='. $username .'&password='. $password);
        // if($login){
        //     $result = $this->curl('http://209.97.179.175/panel/tambahcommentz.php','urlnyax='.request()->url.'&commentar='.request()->comment);
        // }
        
        $x = count(explode(PHP_EOL, request()->comment));
        if($x > 10){
            \App\Delay::where('user_id', auth()->user()->id)->update(['comment' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . 24 . ' hour'))]);
            return back();
        }
        $delay = 10;
        // \App\Delay::where('user_id', auth()->user()->id)->update(['comment' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . $delay . ' minute'))]);
            
        // if($x <= 5){
        //     $delay = 1;
        // }else if($x <= 25){
        //     $delay = 4;
        // }else if($x <= 50){
        //     $delay = 8;
        // }else{
        //     $delay = 15;
        // }
        
        // if($x <= 25){
        //                 $delay = 3;
        //             }else if($x <= 50){
        //                 $delay = 7;
        //             }else{
        //                 $delay = 15;
        //             }
        
        // if(request()->jumlah > 20){
        //     \App\Delay::where('user_id', auth()->user()->id)->update(['comment' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . 24 . ' hour'))]);
            
        //     return back();
        // }
        
        // $cek = \App\History::where('submitted_by', \Auth::User()->username)
        //                                     ->where('type', 'comment')
        //                                     ->count();
        // $cekday = \App\History::where('submitted_by', \Auth::User()->username)
        //             ->where('type', 'comment')
        //             ->whereDate('created_at', '=', date('Y-m-d'))->count();
        // if($cekday <= 4){
            

            
            
        //         $post_link = request()->url;
        //         $post_quantity = request()->jumlah;
        //         $order_postdata = "key=$key&action=add&service=1171&link=$post_link&quantity=$post_quantity";
        //         $ch = curl_init();
        //         curl_setopt($ch, CURLOPT_URL, "https://justanotherpanel.com/api/v2");
        //         curl_setopt($ch, CURLOPT_POST, 1);
        //         curl_setopt($ch, CURLOPT_POSTFIELDS, $order_postdata);
        //         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        //         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        //         $chresult = curl_exec($ch);
        //         curl_close($ch);
        //         $order_data = json_decode($chresult, true);
                
        //         $poid = $order_data['order'];
        //         if(isset($poid)){
                    
        //             if($level == "admin"){
        //                 $delay = 0;
        //             }else{
        //                 $delay = 20;
        //             }
                    
        //             \App\Delay::where('user_id', auth()->user()->id)->update(['comment' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . $delay . ' minute'))]);
                    
        //             $history = new \App\History;
        //             $history->submitted_by = auth()->user()->username;
        //             $history->target = request()->url;
        //             $history->type = 'Comment';
        //             $history->total_submit = count(explode(PHP_EOL, request()->comment));
                    
                    
        //             $history->ip = $_SERVER['REMOTE_ADDR'];
        //             $history->save();
                    
                    
                    
        //             $pesan = 'SUKSES';
        //             session()->flash('result', $pesan);
        //             return back();
                    
        //         }else{
        //             $pesan = 'GAGAL';
        //             session()->flash('result', $pesan);
        //             return back();
        //         }

        // }else{
        //     $pesan = 'LIMIT';
        //     session()->flash('result', $pesan);
        //     return back();
        // }
        
        // $apiku = 'https://instagramaf.supardi.net/ivanx.php?key=asbh2bkac88';
        // $result = $this->curl($apiku,'url='.request()->url.'&jumlah='.$x.'&server=komen&quantity='.$x.'&komentar='.request()->comment);
          $history = new \App\History;
                    $history->submitted_by = auth()->user()->username;
                    $history->target = request()->url;
                    $history->type = 'Comment';
                    $history->total_submit = count(explode(PHP_EOL, request()->comment));
                    
                    
                    $history->ip = $_SERVER['REMOTE_ADDR'];
                    $history->save();
        
        $apiku = 'https://instagramaf.supardi.net/ivanx.php?key=asbh2bkac88';
        $result = $this->curl($apiku,'url='.request()->url.'&jumlah='.$x.'&server=komen&komentar='.request()->comment);
        
        dd($result);
        
        
        $pesan = 'SUKSES';
                    session()->flash('result', $pesan);
                    return back();
        
        
        
        
        
        
        // \App\Delay::where('user_id', auth()->user()->id)->update(['comment' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . $delay . ' minute'))]);
        
        
    }
    
    public function datalc(){
        // $like = 'like_3';
        // if(\Carbon\Carbon::now() < auth()->user()->delay->$like){
        //     return abort(505);
        // }
        
        // if(auth()->check()){
                

        //         $level = auth()->user()->level;
        //         if($level == 'admin'){
        //             $delay = 1;
        //         }else{
        //             // if(request()->jumlah <= 25){
        //             //     $delay = 3;
        //             // }else if(request()->jumlah <= 50){
        //             //     $delay = 7;
        //             // }else{
        //             //     $delay = 15;
        //             // }
        //             $delay = 3;
        //         }
        //     }

        
        // \App\Delay::where('user_id', auth()->user()->id)->update(['like_3' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . $delay . ' minute'))]);
        // $level = auth()->user()->level;
        // if($level == 'member'){
        //     if(request()->jumlah > 100){
        //             \App\Delay::where('user_id', auth()->user()->id)->update(['like_3' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . 24 . ' hours'))]);
        //             return back();
        //         }
        // }
        
                
        // if($level == 'admin'){
        //     if(request()->jumlah > 100){
        //             \App\Delay::where('user_id', auth()->user()->id)->update(['like_3' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . 24 . ' hours'))]);
        //             return back();
        //         }
        // }
        
        
        
        dd($this->curl('http://vadgram.me/login.php', 'username=Palkon1&password=8599') == TRUE);
        
        if($login == true){
            echo "LOG";
        }
        
        // $url = 'https://fast-pedia.id/api/api.php?username='.trim(request()->username);

        // $ch = curl_init();
        // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // curl_setopt($ch, CURLOPT_URL,$url);
        // $result=curl_exec($ch);
        // curl_close($ch);
        
        // $jd = json_decode($result, true);
        
        // set_time_limit(0);
        // $c = curl_init('https://api.instagram.com/oembed/?url='.trim(request()->url));
        // curl_setopt($c,CURLOPT_RETURNTRANSFER,1);
        // curl_setopt($c,CURLOPT_SSL_VERIFYPEER,0);
        // curl_setopt($c,CURLOPT_USERAGENT,"SEBASTIANW-PC 11/23.01.78.64 Recognized as Mozilla(AppleWebKit SPA)");
        // $x = curl_exec($c);
        // $xinfo = curl_getinfo($c);
        // curl_close($c);
        
        
        // if ($xinfo['http_code'] !== 200) {
        //     $mediaid = null;
        // } else {
        //     $mediaid = json_decode($x);
        //     $mediaid = $mediaid->media_id;
        //     $mediaid = explode("_", $mediaid);
        //     $mediaid = $mediaid[0];
        // }
        // $data['userid']     = $jd['graphql']['user']['id'];
        // $data['jumlah']     = request()->jumlah;
        // $data['mediaid']    = $mediaid;
        
        // $data['username']     = request()->username;
        // $data['jumlah']     = request()->jumlah;
        // $data['url']    = request()->url;
        
        // $result = $this->curlLC($data);
        
        
        
        // $history = new \App\History;
        // $history->submitted_by = auth()->user()->username;
        // $history->target = request()->url;
        // $history->type = 'Like in Comment';
        // $history->total_submit = request()->jumlah;
        
        // $history->ip = $_SERVER['REMOTE_ADDR'];
        // $history->save();
        
        // session()->flash('result', $result);
        
        // return redirect('/service/likecomment');
        
    }
    
    public function dataVS()
    {   
        $like = 'like_4';
        if(\Carbon\Carbon::now() < auth()->user()->delay->$like){
            return abort(505);
        }
        
        if(auth()->check()){
                

                $level = auth()->user()->level;
                if($level == 'admin'){
                    $delay = 1;
                }else{
                    $delay = 15;
                }
            }
        
        \App\Delay::where('user_id', auth()->user()->id)->update(['like_3' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . $delay . ' minute'))]);
        if(request()->jumlah > 1000){
                    \App\Delay::where('user_id', auth()->user()->id)->update(['like_3' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . 24 . ' hours'))]);
                    return back();
                }
        
        // $url = 'https://fast-pedia.id/api/api.php?username='.trim(request()->username);
        // $ch = curl_init();
        // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // curl_setopt($ch, CURLOPT_URL,$url);
        // $result=curl_exec($ch);
        // curl_close($ch);
        
        // $jd = json_decode($result, true);
        
        $history = new \App\History;
        $history->submitted_by = auth()->user()->username;
        $history->target = request()->username;
        $history->type = 'Story Views';
        $history->total_submit = request()->jumlah;
        
        $history->ip = $_SERVER['REMOTE_ADDR'];
        $history->save();
        
        // $data['userid']     = $jd['graphql']['user']['id'];
        // $data['jumlah']     = request()->jumlah;
        // $data['token']      = 'HoDolon05161.uhz';
        
        $data['username']     = request()->username;
        $data['jumlah']     = request()->jumlah;
        
        
        $result = $this->curlVS($data);
        
        
        
        session()->flash('result', $result);
        
        return redirect('/service/story');
        
    }
    
    public function dataVS1()
    {   
        $like = 'like_4';
        if(\Carbon\Carbon::now() < auth()->user()->delay->$like){
            return abort(505);
        }
        
        if(auth()->check()){
                

                $level = auth()->user()->level;
                if($level == 'admin'){
                    $delay = 0;
                }else{
                    $delay = 6;
                }
            }
        
        
        
        // $url = 'https://fast-pedia.id/api/api.php?username='.trim(request()->username);
        // $ch = curl_init();
        // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // curl_setopt($ch, CURLOPT_URL,$url);
        // $result=curl_exec($ch);
        // curl_close($ch);
        
        // $jd = json_decode($result, true);
        
        $history = new \App\History;
        $history->submitted_by = auth()->user()->username;
        $history->target = request()->username;
        $history->type = 'Story Views';
        $history->total_submit = request()->jumlah;
        
        $history->ip = $_SERVER['REMOTE_ADDR'];
        $history->save();
        
        // $data['userid']     = $jd['graphql']['user']['id'];
        // $data['jumlah']     = request()->jumlah;
        // $data['token']      = 'HoDolon05161.uhz';
        
        $data['username']     = request()->username;
        $data['jumlah']     = request()->jumlah;
        
        
        $order_postdata = "key=00df632e94340a29e4f0bc062cea93af&action=add&service=900&link=".$data['username']."&quantity=".$data['jumlah'];	
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, 'https://justanotherpanel.com/api/v2');
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $order_postdata);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                $chresult = curl_exec($ch);
                curl_close($ch);
                $order_data = json_decode($chresult, true);
                
                if(isset($order_data['order'])){
                    \App\Delay::where('user_id', auth()->user()->id)->update(['like_4' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . $delay . ' hours'))]);
                    if(request()->jumlah > 500){
                                \App\Delay::where('user_id', auth()->user()->id)->update(['like_4' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . 24 . ' hours'))]);
                                return back();
                            }
                    $result = 'SUKSES';
                }else{
                    $result = 'GAGAL';
                }
        
        
        
        session()->flash('result', $result);
        
        return redirect('/service/storys');
        
    }
    
    public function curlLC($data)
    {
        // $urlServer = 'https://panel-fp.com/ApiPrivate/likesKoment.php?mediaid='.$data['mediaid'].'&count='.$data['jumlah'].'&userid='.$data['userid'];
        
        $urlServer = 'http://209.97.179.175/curl/ivkomlike.php?url='.$data['url'].'&username='.$data['username'].'&jumlah='.$data['jumlah'];
        $ca = curl_init();
        curl_setopt($ca, CURLOPT_URL, $urlServer);
        curl_setopt($ca, CURLOPT_RETURNTRANSFER, 1);
        
        // $data = array(
        //             'mediaid'  => $data['mediaid'],
        //             'count' => $data['jumlah'],
        //             'userid'=> $data['userid'],
        //          );
        
        $data = array(
                    
                    'quantity' => $data['jumlah'],
                    'username'=> $data['username'],
                    'url'=> $data['url'],
                 );
                 
        curl_setopt($ca,CURLOPT_TIMEOUT, 5);
        
        $za = curl_exec($ca);
        curl_close($ca);

        return $za;
    }
    
    public function curlVS($data)
    {
        
        // $urlServer = 'https://panel-fp.com/TambahPrivate/api/addviewsSG.php?user_idz='.$data['userid'].'&jumlah='.$data['jumlah'].'&token_akses='.$data['token'];
        $urlServer = 'http://209.97.179.175/curl/ivstory.php?username='.$data['username'].'&jumlah='.$data['jumlah'];
        
        $ca = curl_init();
        curl_setopt($ca, CURLOPT_URL, $urlServer);
        curl_setopt($ca, CURLOPT_RETURNTRANSFER, 1);
        

        curl_setopt($ca,CURLOPT_TIMEOUT, 5);
        
        $za = curl_exec($ca);
        curl_close($ca);

        return $za;
    }
    
    public function curlC($data)
    {
        //CURL TARO SINI NANTI pakai parameter
//         $urlServer = 'http://209.97.129.35/bowoluvifan.php';
//         $ca = curl_init();
//         curl_setopt($ca, CURLOPT_URL, $urlServer);
        
//         curl_setopt($ca,CURLOPT_SSL_VERIFYPEER, false);
// 		curl_setopt($ca,CURLOPT_POST,1);
// 		curl_setopt($ca,CURLOPT_RETURNTRANSFER,TRUE);
// 		curl_setopt($ca,CURLOPT_POST,TRUE);
// 		curl_setopt($ca,CURLOPT_POSTFIELDS, "urlxx=$data['url']&komeng=$data['comment']");
// 		curl_setopt($ca, CURLOPT_RETURNTRANSFER,1);		
// 		curl_setopt($ca,CURLOPT_USERAGENT,"Haqny-PC 11/23.01.78.64 Recognized as Mozilla(AppleWebKit SPA)");
		
        
//         curl_setopt($ca,CURLOPT_TIMEOUT, 10);
        
//         $za = curl_exec($ca);
//         curl_close($ca);

//         return $za;

        // $urlServer = 'http://209.97.129.35/bowoluvifan.php?urlxx='.$data['url'].'&komeng='.$data['comment'];

        // $ca = curl_init();
        // curl_setopt($ca, CURLOPT_URL, $urlServer);
        // curl_setopt($ca, CURLOPT_RETURNTRANSFER, 1);
        

        // curl_setopt($ca,CURLOPT_TIMEOUT, 10);
        
        // $za = curl_exec($ca);
        // curl_close($ca);

        // return $za;
    }
    
    function proses($url,$params,$username,$password){
            
    	 $ch = curl_init();
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, "username=$username&password=$password");
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_COOKIEJAR, "-");
         curl_setopt($ch, CURLOPT_COOKIEFILE, "-");
         $result = curl_exec($ch);
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
         $result = curl_exec($ch);
         curl_close($ch);
    }
    
    public function curl($url, $postdata = ''){
    	$ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        if($postdata !== ''){
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
        }
        curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
        curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: ' . strlen($postdata))                                                                       
);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
    
    public function vp(){
        $cekdata = "";
        return view('server.viewpost')->with('cekdata', $cekdata);
    }
    
    public function datavp(){
        
        if(\Auth::User()->username == 'Demo'){
            $pesan = 'SUKSES';
            session()->flash('result', $pesan);
            return back();
        }
        
        
        $nowz = date('Y-m-d');
        $nano = DB::table('users_history')->where('submitted_by', auth()->user()->username)->where('type', 'Post Views')->whereDate('created_at', $nowz)->count();
        
        
        
        
        if($nano > 5){
            
            $pesan = 'GAGAL';
            session()->flash('result', $pesan);
            return back();
        }
        
        \App\Delay::where('user_id', auth()->user()->id)->update(['like_10' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . 10 . ' minute'))]);
        
        if(request()->jumlah > 1000){
            \App\Delay::where('user_id', auth()->user()->id)->update(['like_10' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . 24 . ' hour'))]);
            $history = new \App\History;
            $history->submitted_by = auth()->user()->username;
            $history->target = request()->url;
            $history->type = 'BUG';
            $history->total_submit = request()->jumlah;
            
            $history->ip = $_SERVER['REMOTE_ADDR'];
            $history->save();
            return back();
        }
        
        $jml = request()->jumlah;
        $target = request()->url;
        $order_postdata = "key=00df632e94340a29e4f0bc062cea93af&action=add&service=260&link=$target&quantity=$jml";	
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://justanotherpanel.com/api/v2');
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $order_postdata);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $chresult = curl_exec($ch);
        curl_close($ch);
        
        
        
        $history = new \App\History;
        $history->submitted_by = auth()->user()->username;
        $history->target = request()->url;
        $history->type = 'Post Views';
        $history->total_submit = request()->jumlah;
        
        $history->ip = $_SERVER['REMOTE_ADDR'];
        $history->save();
                
        $pesan = 'SUKSES';
        session()->flash('result', $pesan);
        return back();
        
    }
    
    
    
}

?>