|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Models; |
| 4 | + |
| 5 | +use Database\Factories\RegistryFactory; |
| 6 | +use Illuminate\Database\Eloquent\Attributes\Fillable; |
| 7 | +use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 8 | +use Illuminate\Database\Eloquent\Model; |
| 9 | + |
| 10 | +#[Fillable([ |
| 11 | + 'name', 'type', 'title', 'description', 'author', |
| 12 | + 'dependencies', 'devDependencies', 'registryDependencies', |
| 13 | + 'files', 'tailwind', 'envVars', 'docs', 'categories', |
| 14 | + 'extends', 'style', 'iconLibrary', 'baseColor', 'theme', |
| 15 | + 'meta', 'font', 'css_vars', 'css', |
| 16 | +])] |
| 17 | +class Registry extends Model |
| 18 | +{ |
| 19 | + /** @use HasFactory<RegistryFactory> */ |
| 20 | + use HasFactory; |
| 21 | + |
| 22 | + protected $casts = [ |
| 23 | + 'meta' => 'array', |
| 24 | + 'font' => 'array', |
| 25 | + 'css_vars' => 'array', |
| 26 | + 'css' => 'array', |
| 27 | + 'dependencies' => 'array', |
| 28 | + 'devDependencies' => 'array', |
| 29 | + 'registryDependencies' => 'array', |
| 30 | + 'files' => 'array', |
| 31 | + 'tailwind' => 'array', |
| 32 | + 'envVars' => 'array', |
| 33 | + 'categories' => 'array', |
| 34 | + ]; |
| 35 | + |
| 36 | + public function scopeThemes($query) |
| 37 | + { |
| 38 | + return $query->where('type', 'registry:theme'); |
| 39 | + } |
| 40 | + |
| 41 | + public function scopeFonts($query) |
| 42 | + { |
| 43 | + return $query->where('type', 'registry:font'); |
| 44 | + } |
| 45 | + |
| 46 | + public function scopeLib($query) |
| 47 | + { |
| 48 | + return $query->where('type', 'registry:lib'); |
| 49 | + } |
| 50 | + |
| 51 | + public function scopeUi($query) |
| 52 | + { |
| 53 | + return $query->where('type', 'registry:ui'); |
| 54 | + } |
| 55 | + |
| 56 | + public function scopeComponent($query) |
| 57 | + { |
| 58 | + return $query->where('type', 'registry:component'); |
| 59 | + } |
| 60 | + |
| 61 | + protected function scopeSearch($query, $search) |
| 62 | + { |
| 63 | + return $query->where('name', 'like', "%{$search}%"); |
| 64 | + } |
| 65 | +} |
0 commit comments