Design Refresh
This commit is contained in:
parent
1dee7ae516
commit
e7202174f7
44 changed files with 593 additions and 228 deletions
|
|
@ -4,16 +4,31 @@
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BookmarkSite extends Model {
|
||||
use HasFactory;
|
||||
protected $table = "bookmark__sites";
|
||||
protected $fillable = ['name', 'description', 'url', 'category'];
|
||||
|
||||
public function category() {
|
||||
public function category(): BelongsTo {
|
||||
return $this->belongsTo(BookmarkCategory::class, 'category');
|
||||
}
|
||||
public static function insertBookmark(string $name, string $url, int $category) {
|
||||
|
||||
public static function create(Request $request): BookmarkSite {
|
||||
$category = BookmarkCategory::where('id', $request->get('category'))->firstOrFail();
|
||||
$newSite = new BookmarkSite;
|
||||
$newSite->name = $request->get('name');
|
||||
$newSite->url = $request->get('url');
|
||||
$newSite->description = $request->get('description');
|
||||
$newSite->category = $category->id;
|
||||
$newSite->save();
|
||||
return $newSite;
|
||||
}
|
||||
|
||||
public static function insertBookmark(string $name, string $url, int $category): void {
|
||||
$category = BookmarkCategory::where('id', $category)->firstOrFail();
|
||||
$newBookmark = new BookmarkSite;
|
||||
$newBookmark->name = $name;
|
||||
|
|
@ -21,15 +36,4 @@ public static function insertBookmark(string $name, string $url, int $category)
|
|||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue