i have query:
$amount = input::get('amount'); // first getting age range input in html (name="amount"). $amount = str_replace(' ','',$amount); //remove blank spaces between ages value, if there's any. $amount = explode('-',$amount); // breaking value 16-45, 16 , 45, '-' being breaking point. , turns value array. // getting array value index 0 , 1. $min = $amount[0]; $max = $amount[1]; $user = $request->user(); $userselect = input::get('select_preferences'); $prefquery = profile::wherehas('expectations', function($query) use($userselect) { $query->wherein('name', $userselect); // first query: compare name column in expectations table user selection. //now chain query: })->wherebetween('age', [$min,$max]) ->with('user', 'expectations')->get();
i trying user selection , age range. when running dump($prefquery);
- getting empty collection:
collection {#192 ▼ #items: [] }
here's profile model being queried:
<?php namespace app; use illuminate\database\eloquent\model; class profile extends model { protected $table = 'profiles'; protected $fillable = ['gender','age','goals','activitytype']; /** * profile belongs many expectations * @return illuminate\database\eloquent\relations\belongstomany */ public function expectations() { return $this->belongstomany('app\expectation'); } /** * profile belong user * @return illuminate\database\eloquent\relations\belongsto */ public function user() { return $this->belongsto('app\user'); //belongsto relationship profile model user model. } }
why getting empty collection although making widest search possible?
Comments
Post a Comment