Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Origin | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| user | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAll | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| findById | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 6 | use Illuminate\Database\Eloquent\Model; |
| 7 | |
| 8 | class Origin extends Model |
| 9 | { |
| 10 | use HasFactory; |
| 11 | |
| 12 | protected $table = 'origins'; |
| 13 | |
| 14 | protected $fillable = |
| 15 | [ |
| 16 | 'name', |
| 17 | 'slug', |
| 18 | 'thumbnail', |
| 19 | 'description', |
| 20 | 'created_by', |
| 21 | ]; |
| 22 | |
| 23 | /** |
| 24 | * ########################################### |
| 25 | * # Repository Methods Start # |
| 26 | * ########################################### |
| 27 | * */ |
| 28 | public function user() |
| 29 | { |
| 30 | return $this->belongsTo(User::class, 'created_by'); |
| 31 | } |
| 32 | |
| 33 | public static function getAll($is_pluck = false) |
| 34 | { |
| 35 | $query = self::query()->with('user'); |
| 36 | $query->latest(); |
| 37 | |
| 38 | return $is_pluck ? $query->pluck('name', 'id') : $query->cursor(); |
| 39 | } |
| 40 | |
| 41 | public static function findById($id) |
| 42 | { |
| 43 | |
| 44 | return self::query()->findOrFail($id); |
| 45 | } |
| 46 | /** |
| 47 | * ########################################### |
| 48 | * # Repository Methods END # |
| 49 | * ########################################### |
| 50 | * */ |
| 51 | } |