i have this trait which i want to use dependency injection
<?php
namespace App\Http\Controllers\Admin;
trait ControllerTrait{
public function index($this->model $payroll){
return $this->model->paginate(20);
}
}
the controller which uses this trait
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Payroll;
class PayrollController extends Controller
{
use ControllerTrait;
public $model = "Payroll";
}
$model now is a string how to convert it to an object in calling index method of the trait