403Webshell
Server IP : 66.29.132.124  /  Your IP : 18.222.161.57
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/wavevlvu/book24.ng/modules/Flight/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/wavevlvu/book24.ng/modules/Flight/Controllers/AirportController.php
<?php


    namespace Modules\Flight\Controllers;


    use Auth;
    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\DB;
    use Illuminate\Support\Facades\Validator;
    use Illuminate\Validation\Rule;
    use Maatwebsite\Excel\Facades\Excel;
    use Modules\AdminController;
    use Modules\Flight\Imports\AirportImportIATA;
    use Modules\Flight\Models\Airport;
    use Modules\Flight\Models\Flight;
    use Modules\Flight\Models\SeatType;
    use Modules\Flight\Resources\AirportResource;
    use Modules\Location\Models\Location;

    class AirportController extends AdminController
    {
        /**
         * @var string
         */
        private $airport;
        /**
         * @var string
         */
        private $location;

        /**
         * @var string
         */

        public function __construct()
        {
            parent::__construct();
            $this->location = Location::class;
            $this->airport = Airport::class;
        }

        public function search(Request $request)
        {
            $pre_selected = $request->query('pre_selected');
            $selected = $request->query('selected');

            if($pre_selected && $selected){
                $item = $this->airport::find($selected);
                if(empty($item)){
                    return response()->json([
                        'title'=>''
                    ]);
                }else{
                    return response()->json([
                        'title'=>$item->name
                    ]);
                }
            }
            $s = $request->query('search');
            $query = $this->airport::select('id', 'name','code','address','country');
            if ($s) {
                $query->where(function($query) use($s){
                    $query->where('name', 'LIKE', '%'.$s.'%');
                    $query->orWhere('address', 'LIKE', '%'.$s.'%');
                    $query->orWhere('code', $s);
                    $query->orWhere('country', $s);
                });
                $query->orderByRaw("
                    CASE WHEN code = ? then 1
                    When `name` like '%?%' then 2
                    When `address` like '%?%' then 3
                    When `country` = ? then 4
                    ELSE 5
                    END ASC
                ",[$s,$s,$s,$s]);
            }
            $res = $query->orderBy('id', 'desc')->limit(20)->get();
            return [
                'status'=>1,
                'data'=>AirportResource::collection($res)
            ];
        }

    }

Youez - 2016 - github.com/yon3zu
LinuXploit