I often need to perform this query:
$Op = JobCardOp::where([
['JobCardNum', '=', $JobCardNum ],
['OpNum', '=', $OpNum ]
])->first();
So rather than writing this out every time I want a function like:
public function getOp($JobCardNum, $OpNum)
{
$Op = JobCardOp::where([
['JobCardNum', '=', $JobCardNum ],
['OpNum', '=', $OpNum ]
])->first();
return $Op;
}
That I can call in my controller. Where should I define my function, at the moment the I only need it in one controller but I may need it an another if thats possible. Any help appreciated.