I am looking to stay DRY across controllers in my Laravel 5 application. The route I have chosen is to use a Trait with methods that I can apply to my separate controllers.
The methods in my Trait need to act upon different Model classes. They are always subclasses of the Eloquent model.
Here was my attempt:
<?php namespace Conjunto\Traits;
use Illuminate\Database\Eloquent\Model;
trait SortableTrait
{
/**
*
*/
public function upPosition(Model $model)
{
dd($model);
}
}
I am unfortunately getting the following error, since the Eloquent Model itself is not instantiable:
Target [Illuminate\Database\Eloquent\Model] is not instantiable.
How could I still make this work with a Trait?