2 weeks ago

Anyway to pass parameter into eloquent function?

Posted 2 weeks ago by kankai

Hi guys,

I'm new to eloquent, is that anyway to pass parameter to eloquent function?

current game_id model

 public function detail(){
        return $this->hasMany('App\gamedata','game_id','game_id')->where('status',0);

my controller

     $inputValue = $request->wallet;
        $data = game_id::with('detail')->where('wallet', $inputValue)->get();
    return view('playerfilter', compact('data'));

What i need is pass select date from controller to model there, something like this.

public function detail($date){
        return $this->hasMany('App\gamedata','game_id','game_id')->whereDate('created_at', $date)->where('status',0);

Please sign in or create an account to participate in this conversation.