Restyled by php-cs-fixer
This commit is contained in:
parent
ba9fa0f12a
commit
711ac93cb9
17 changed files with 74 additions and 47 deletions
|
|
@ -5,26 +5,30 @@
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BookmarkSite extends Model {
|
||||
class BookmarkSite extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = "bookmark__sites";
|
||||
protected $fillable = ['name', 'description', 'url', 'category'];
|
||||
|
||||
public function category() {
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(BookmarkCategory::class, 'category');
|
||||
}
|
||||
public static function insertBookmark(string $name, string $url, int $category) {
|
||||
public static function insertBookmark(string $name, string $url, int $category)
|
||||
{
|
||||
$category = BookmarkCategory::where('id', $category)->firstOrFail();
|
||||
$newBookmark = new BookmarkSite;
|
||||
$newBookmark = new BookmarkSite();
|
||||
$newBookmark->name = $name;
|
||||
$newBookmark->url = $url;
|
||||
$newBookmark->category = $category->id;
|
||||
$newBookmark->save();
|
||||
}
|
||||
|
||||
public static function importBookmark(array $data) {
|
||||
public static function importBookmark(array $data)
|
||||
{
|
||||
foreach ($data as $site) {
|
||||
$newBookmark = new BookmarkSite;
|
||||
$newBookmark = new BookmarkSite();
|
||||
$newBookmark->name = $site['name'];
|
||||
$newBookmark->description = $site['description'];
|
||||
$newBookmark->url = $site['url'];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue