I have this variable on class/Controller level $songRating and i am calling this method through ajax, when i first time call this method it runs the if block which is good. and now $songRating should be 1.
But this is not a case. When i call this method it again runs the if block. Dont know why :/
public $songRating;
public function GetHighRatedSong()
{
if($this->songRating == null){
$this->songRating=1;
}else{
$this->songRating=2;
}
return response()->json($this->songRating);
}