diff options
author | Frankie B <git@diskfloppy.me> | 2024-06-11 18:02:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-11 18:02:01 +0100 |
commit | 0f52d80ca67a49258b235f5831163dd72fbd54cf (patch) | |
tree | 9c5cd36b6e0a233e09ac88a4409fb68c63e4781a /app/Models/BookmarkSite.php | |
parent | a64bcc2c4639d5804b6dada23151bfcb8b198121 (diff) |
Merge MVC rewrite into master (#21)
* Just commit it all
* Require auth
* crap
* Update homepage
* Block AI scrapers
* Update cache update script
* Add dummy file
* Remove unnecessary lastfm config var
* Use withQueryParameters for LastFM API
* Fix embeds
* Update example env
* Smard
Diffstat (limited to 'app/Models/BookmarkSite.php')
-rw-r--r-- | app/Models/BookmarkSite.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/Models/BookmarkSite.php b/app/Models/BookmarkSite.php new file mode 100644 index 0000000..3c9cc5d --- /dev/null +++ b/app/Models/BookmarkSite.php @@ -0,0 +1,35 @@ +<?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(); + } + } +} |