VaKeR CYBER ARMY
Logo of a company Server : Apache
System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
User : vapecompany ( 2719)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/thread-self/root/home/vapecompany/demo.vapecompany.com.bd/app/Http/Controllers/Backend/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/thread-self/root/home/vapecompany/demo.vapecompany.com.bd/app/Http/Controllers/Backend/BankController.php
<?php

namespace App\Http\Controllers\Backend;

use App\Models\Bank;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\User;

class BankController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    // public function __construct()
    // {
    //     $this->middleware('auth');
       
    // } 
   public function index()
    {
        // if(!auth()->user()->canEvent('all_bank'))
        // {
        //     return redirect('/');
        // }
        $banks = Bank::get();
        return view('backend.bank.index',['banks'=>$banks]);
    }

    function get_all(Request $request){
        
        $draw = $request->get('draw');
        $start = $request->get("start");
        $rowperpage = $request->get("length"); // Rows display per page

        $columnIndex_arr = $request->get('order');
        $columnName_arr = $request->get('columns');
        $order_arr = $request->get('order');
        $search_arr = $request->get('search');

        $columnIndex = $columnIndex_arr[0]['column']; // Column index
        $columnName = $columnName_arr[$columnIndex]['data']; // Column name
        $columnSortOrder = $order_arr[0]['dir']; // asc or desc
        $searchValue = $search_arr['value']; // Search value

        $totalRecords = Bank::count();
        $couriers =Bank::orderBy('bank_id', 'desc');
        if($columnName_arr[0]['search']['value'] != null){
            $couriers=$couriers->Where('bank_id', 'like', $columnName_arr[0]['search']['value'] . '%');
        }
        if($columnName_arr[1]['search']['value'] != null){
            $couriers=$couriers->Where('bank_name', 'like', $columnName_arr[1]['search']['value'] . '%');
        }
        if($columnName_arr[2]['search']['value'] != null){
            $couriers=$couriers->Where('bank_email', 'like', $columnName_arr[2]['search']['value'] . '%');
        }
        if($columnName_arr[3]['search']['value'] != null){
            $couriers=$couriers->Where('bank_phone', 'like', $columnName_arr[3]['search']['value'] . '%');
        }
        if($columnName_arr[4]['search']['value'] != null){
            $couriers=$couriers->Where('bank_mobile', 'like', $columnName_arr[4]['search']['value'] . '%');
        }
        if($columnName_arr[5]['search']['value'] != null){
            $couriers=$couriers->Where('bank_website', 'like', $columnName_arr[5]['search']['value'] . '%');
        }
        if($columnName_arr[6]['search']['value'] != null){
            $couriers=$couriers->Where('bank_address', 'like', $columnName_arr[6]['search']['value'] . '%');
        }
        if($columnName_arr[7]['search']['value'] != null){
            $couriers=$couriers->Where('status', 'like', $columnName_arr[7]['search']['value'] . '%');
        }
            // ->where('bank_id', 'like', $searchValue . '%')
            // ->orWhere('bank_name', 'like', $searchValue . '%')
            // ->orWhere('bank_address', 'like', $searchValue . '%')
            // ->orWhere('bank_email', 'like',$searchValue . '%')
            // ->orWhere('bank_phone', 'like', $searchValue . '%')
            // ->orWhere('bank_mobile', 'like', $searchValue . '%')
            // ->orWhere('bank_website', 'like', $searchValue . '%')
        if($rowperpage < 0) {
            $rowperpage = 8999999999999999999;
        }
        $couriers=$couriers->skip($start)
            ->take($rowperpage)
            ->get();
        $data_arr = array();
        foreach($couriers as $courier){
            
            $action ='<div role="group" aria-label="Basic example" class="btn-group btn-group-sm">';
        //     if(auth()->user()->canEvent('edit_bank'))
        // {
            $action .='<a href="'.url('admin/edit_bank/'.$courier->bank_id).'" class="mr-2">
                                                        <i class="fa fa-edit text-warning"></i>
                                                    </a>';
        // }
            $action .='</div>';
          
                                               
            $data_arr[] = array(
                "bank_id" => $courier->bank_id,
                "bank_name" => $courier->bank_name,
                "bank_address" => $courier->bank_address,
                "bank_email" => $courier->bank_email,
                "bank_phone" => $courier->bank_phone,
                "bank_mobile" => $courier->bank_mobile,
                "status" => $courier->status == 1 ? 'Active' : 'In Active',
                "bank_website" => $courier->bank_website,
                "Action" => $action,
            );
        }
        $response = array(
            "draw" => intval($draw),
            "recordsTotal" => $totalRecords,
            "recordsFiltered" => $totalRecords,
            "data" => $data_arr
        ); 

        echo json_encode($response);
        exit;
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        // if(!auth()->user()->canEvent('new_bank'))
        // {
        //     return redirect('/');
        // }
        return view('backend.bank.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $validator = \Validator::make($request->all(), [
            'bank_name' => 'required|unique:banks|max:150',
            'bank_address' => 'required|max:150',
            'bank_email' => 'max:150',
            'bank_phone' => 'max:20',
            'bank_mobile' => 'max:20',
            'bank_website' => 'max:150',
           
        ]);
        
        if ($validator->fails())
        {
            return response()->json(['errors'=>$validator->errors()->all()]);
        }else{
           //return  response()->json(['re'=> auth()->user()->user_id]);
            $bank =  new Bank;
            $bank->bank_name = $request->bank_name;
             $bank->bank_address = $request->bank_address;
              $bank->bank_email = $request->bank_email;
               $bank->bank_phone = $request->bank_phone;
                $bank->bank_mobile = $request->bank_mobile;
                 $bank->bank_website = $request->bank_website;
                 $bank->status = $request->status ? $request->status : 0;
            // $bank->created_by = auth()->user()->user_id;
            $bank->save();
        }
        return response()->json(['errors'=>'0','success'=> $request->bank_name.' is successfully added']);
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Brand  $brand
     * @return \Illuminate\Http\Response
     */
    public function show(bank $bank)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\Brand  $brand
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        // if(!auth()->user()->canEvent('edit_bank'))
        // {
        //     return redirect('/');
        // }
        $bank=Bank::where('bank_id',$id)->first();
        return view('backend.bank.edit',['bank'=>$bank]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Brand  $brand
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, bank $bank)
    {
        $id=$request->bank_id;
       $validator = \Validator::make($request->all(), [
            'bank_name' => 'required|max:150|unique:banks,bank_name,'.$id.',bank_id',

            'bank_address' => 'required|max:150',
            'bank_email' => 'max:150',
            'bank_phone' => 'max:20',
            'bank_mobile' => 'max:20',
            'bank_website' => 'max:150',
           
        ]);
        
        if ($validator->fails())
        {
            return response()->json(['errors'=>$validator->errors()->all()]);
        }else{
           //return  response()->json(['re'=> auth()->user()->user_id]);
            $bank =  Bank::find($request->bank_id);
            $bank->bank_name = $request->bank_name;
             $bank->bank_address = $request->bank_address;
              $bank->bank_email = $request->bank_email;
               $bank->bank_phone = $request->bank_phone;
                $bank->bank_mobile = $request->bank_mobile;
                 $bank->bank_website = $request->bank_website;
            $bank->status = $request->status ? $request->status : 0;
            // $bank->updated_by = auth()->user()->user_id;
            $bank->save();
        }
        return response()->json(['errors'=>'0','success'=> $request->bank_name.' is successfully Updated']);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Brand  $brand
     * @return \Illuminate\Http\Response
     */
    public function destroy(Bank $bank)
    {
        //
    }
}

VaKeR 2022