diff options
Diffstat (limited to 'src/Models/BaseModel.php')
-rw-r--r-- | src/Models/BaseModel.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Models/BaseModel.php b/src/Models/BaseModel.php index cf718e4f..d5ded428 100644 --- a/src/Models/BaseModel.php +++ b/src/Models/BaseModel.php @@ -2,6 +2,8 @@ namespace Engelsystem\Models; +use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; abstract class BaseModel extends Model @@ -10,6 +12,8 @@ abstract class BaseModel extends Model public $timestamps = false; /** + * Create a new model + * * @param array $attributes * @return BaseModel */ @@ -20,4 +24,16 @@ abstract class BaseModel extends Model return $instance; } + + /** + * Find a model by its primary key + * + * @param mixed $id + * @param array $columns + * @return Builder|Builder[]|Collection|Model|null + */ + public static function find($id, $columns = ['*']) + { + return static::query()->find($id, $columns); + } } |