Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]



PHP Snippet 1:

$from = '2017-01-01 00:00:00';
$to = '2018-10-01 00:00:00';
$resorces = DB::select('SELECT * FROM table
    WHERE a BETWEEN ? AND ?
    AND c > ?
    AND d < ?', [$from, $to, $from, $to]);

PHP Snippet 2:

$from = '2017-01-01 00:00:00';
$to = '2018-10-01 00:00:00';
$resorces = DB::table('table')
    ->whereRaw('a BETWEEN ? AND ?', [$from, $to])
    ->whereRaw('c > ?', [$from])
    ->whereRaw('d < ?', [$to])
    ->get();

PHP Snippet 3:

public function scopeQUERY ($query, $value1, $value2){

      $query = DB::(YOUR QUERY);

      return $query;
}

PHP Snippet 4:

public function hello(Model name $Modelname){

         $query = $Modelname->QUERY($value1, $value2);

}