diff options
author | floppydiskette <git@diskfloppy.me> | 2024-08-08 22:22:38 +0100 |
---|---|---|
committer | floppydiskette <git@diskfloppy.me> | 2024-08-08 22:22:38 +0100 |
commit | 04fc009874db2d539ad881b649f7ebb512f05312 (patch) | |
tree | 9934681b96c15ceffbc9ce8d682621ff875f1b4f /app/Models/BookmarkSite.php | |
parent | fc5cd70e729f639aaf1c6ff6a4bf3d5d52664de9 (diff) |
Init rails apprails
Diffstat (limited to 'app/Models/BookmarkSite.php')
-rw-r--r-- | app/Models/BookmarkSite.php | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/app/Models/BookmarkSite.php b/app/Models/BookmarkSite.php deleted file mode 100644 index 3c9cc5d..0000000 --- a/app/Models/BookmarkSite.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace App\Models; - -use Illuminate\Database\Eloquent\Factories\HasFactory; -use Illuminate\Database\Eloquent\Model; - -class BookmarkSite extends Model { - use HasFactory; - protected $table = "bookmark__sites"; - protected $fillable = ['name', 'description', 'url', 'category']; - - public function category() { - return $this->belongsTo(BookmarkCategory::class, 'category'); - } - public static function insertBookmark(string $name, string $url, int $category) { - $category = BookmarkCategory::where('id', $category)->firstOrFail(); - $newBookmark = new BookmarkSite; - $newBookmark->name = $name; - $newBookmark->url = $url; - $newBookmark->category = $category->id; - $newBookmark->save(); - } - - public static function importBookmark(array $data) { - foreach ($data as $site) { - $newBookmark = new BookmarkSite; - $newBookmark->name = $site['name']; - $newBookmark->description = $site['description']; - $newBookmark->url = $site['url']; - $newBookmark->category = $site['category_id']; - $newBookmark->save(); - } - } -} |