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(); } } }