Skip to content

Commit 6b105ac

Browse files
committed
Add loadOnly function to model
1 parent 520dd69 commit 6b105ac

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Eloquent/Model.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Codebarista\LaravelEssentials\Eloquent;
4+
5+
abstract class Model extends \Illuminate\Database\Eloquent\Model
6+
{
7+
public function loadOnly(array|string $relations): array
8+
{
9+
return $this->load($relations)->only($relations);
10+
}
11+
}

0 commit comments

Comments
 (0)