jeudi 20 février 2020

How to add a default "where" clause to a child class?

My question is as follows, I have an interface SportInterface.php as follows:

interface SportInterface
{
    public function fetchFixtures($date_from, $date_to, $page);
    public function updateOdds($fixture_id, $market_id = null);
    public function updateOdd($fixture_id, $market_id, $data);
}

And I also have a "Sport model" which is as follows:

class Sport extends Model implements SportInterface
{
}

And I have a Football model which is as follows:

class Football extends Sport
{

}

Now my question is, I wanted the Football model to use the database table "sports", however - I want a default where claus, Example, instead of doing this:

$football = Sport::where('sport','football')->where('id',3000)->first();

I want to do:

$football = Football::where('id',3000)->first();

Any tips? thank you so much.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire