mardi 28 mai 2019

Search Location From zipcode in laravel

        In User Login One User whos zipcode is 90001 and he wants to search Clinic zipcode 90003 around 5 km in area. after searching he gets 90001 90002 90003 location but in my case its not? why? 
        Check Following Code

In User Login One User whos zipcode is 90001 and he wants to search Clinic zipcode 90003 around 5 km in area. after searching he gets 90001 90002 90003 location but in my case its not? why? Check Following Code

        //Search Controller
        public function filter(Request $request, Trial $trial)
            {
                //Fliter or Search The Gender,Age & zipcode/state/city
                $trial = Trial::query();
                if ($request->has('gender')) {
                    $trial->where('gender' ,$request->gender);
                };

                if ($request->has('age')) {
                    $trial->where('age', $request->age);
                }
                if ($request->has('zipcode')) {
                    $trial->where('zipcode', $request->zipcode)
                          ->orWhere('city', $request->city)
                          ->orWhere('state', $request->state);
                }
                $request = $trial->get();
                return view('search.searchhome',compact('trial'));
            }
        //Model For zipcode distance
 In User Login One User whos zipcode is 90001 and he wants to search Clinic zipcode 90003 around 5 km in area. after searching he gets 90001 90002 90003 location but in my case its not? why? 
    Check Following Code
        public function zipcode(){ //For The Distance Of Two zipcode
                $lat = 25.000;
                $lng = 25.000;

                $trial = Trial::selectRaw('*, ( 6367 * acos( cos( radians( ? ) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians( ? ) ) + sin( radians( ? ) ) * sin( radians( lat ) ) ) ) AS distance', [$lat, $lng, $lat])
                    ->having('distance', '<', 20)
                    ->orderBy('distance')
                    ->get();
            }

        //my Blade
        <form  method="post" action="" class="form-inline"role="form">
                                    

                                <div class="form-group">
                                    <label for="gender" class="sr-only">Gender</label>
                                        <select name="gender" class="form-control col-md-12" required="">
                                            <option value="">Gender</option>
                                            <option value="Male">Male</option>
                                            <option value="Female">Female</option>
                                        </select>
                                </div>
                                <div class="form-group">
                                    <label for="age" class="sr-only">Age</label>
                                        <select name="age" class="form-control" required="">
                                            <option value="">Age</option>

                                            @for ($age = 1; $age <= 100 ; $age++)                  
                                            <option value = ""></option>                  
                                            @endfor
                                        </select>
                                </div>

                                <div class="form-group">
                                    <label for="geo" class="sr-only"></label>
                                        <input type="text" class="form-control col-md-12" name="zipcode" placeholder="City/State or Zip" id = "search" value="" required="" >
                                </div>
                                <p class="clearfix"></p>
                                <div class="form-group">
                                    <label for="distance" class="sr-only">Distance</label>
                                        <select name="distance" class="form-control" required="">
                                            <option value="">Distance </option>
                                            @for ($dis = 1; $dis <= 20 ; $dis++)                  
                                            <option value = "Distance"></option>                  
                                            @endfor
                                        </select>

                                    </div>
                                    <p class="clearfix"></p>
                                    <div class="form-group">
                                        <div class="radio small pull-left">
                                            <label>
                                                <input type="radio" name="health" id="healthy" value="" checked>
                                                I am generally healthy
                                            </label>
                                        </div>
                                        <div class="radio small pull-left">
                                            <label>
                                                <input type="radio" name="health" id="not-healthy" value="">
                                                I have a diagnosed medical condition
                                            </label>
                                        </div>
                                    </div>
                                    <p style="margin-top: 1em; margin-bottom: 1em;">
                                        <button type="submit" class="btn btn-primary pull-right">Find Trials</button>
                                    </p>
                                    <p class="clearfix"></p>
                            </form>
In User Login One User whos zipcode is 90001 and he wants to search Clinic zipcode 90003 around 5 km in area. after searching he gets 90001 90002 90003 location but in my case its not? why? 
        Check Following Code
//has one relationship with User
public function trial(){
        return $this->hasOne('App\Trial','t_id', 'id');
    }

In User Login One User whos zipcode is 90001 and he wants to search Clinic zipcode 90003 around 5 km in area. after searching he gets 90001 90002 90003 location but in my case its not? why? Check Following Code

 In User Login One User whos zipcode is 90001 and he wants to search Clinic zipcode 90003 around 5 km in area. after searching he gets 90001 90002 90003 location but in my case its not? why? 
    Check Following Code



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2I3WuAF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire