Restyled by php-cs-fixer
This commit is contained in:
parent
ba9fa0f12a
commit
711ac93cb9
17 changed files with 74 additions and 47 deletions
|
|
@ -11,23 +11,27 @@ class BookmarkCategory extends Model
|
|||
protected $table = "bookmark__categories";
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function sites() {
|
||||
public function sites()
|
||||
{
|
||||
return $this->hasMany(BookmarkSite::class, 'category');
|
||||
}
|
||||
|
||||
public static function insertBookmarkCategory(string $name) {
|
||||
$newBookmarkCategory = new BookmarkCategory;
|
||||
public static function insertBookmarkCategory(string $name)
|
||||
{
|
||||
$newBookmarkCategory = new BookmarkCategory();
|
||||
$newBookmarkCategory->name = $name;
|
||||
$newBookmarkCategory->save();
|
||||
}
|
||||
public static function selectBookmarks(int $id) {
|
||||
public static function selectBookmarks(int $id)
|
||||
{
|
||||
$bookmarks = BookmarkSite::where('category', '=', $id)->firstOrFail();
|
||||
return $bookmarks;
|
||||
}
|
||||
|
||||
public static function importBookmarkCategory(array $data) {
|
||||
public static function importBookmarkCategory(array $data)
|
||||
{
|
||||
foreach ($data as $category) {
|
||||
$newBookmarkCategory = new BookmarkCategory;
|
||||
$newBookmarkCategory = new BookmarkCategory();
|
||||
$newBookmarkCategory->name = $category['name'];
|
||||
$newBookmarkCategory->priority = intval($category['priority']);
|
||||
$newBookmarkCategory->save();
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ class GuestbookEntry extends Model
|
|||
* @param Request $request The HTTP POST request
|
||||
* @return void
|
||||
*/
|
||||
public static function insertGuestbookEntry(Request $request) {
|
||||
$newEntry = new GuestbookEntry;
|
||||
public static function insertGuestbookEntry(Request $request)
|
||||
{
|
||||
$newEntry = new GuestbookEntry();
|
||||
$newEntry->name = htmlspecialchars($request->get('name'));
|
||||
$newEntry->message = htmlspecialchars($request->get('message'));
|
||||
$newEntry->ip = $request->ip();
|
||||
|
|
@ -28,15 +29,17 @@ public static function insertGuestbookEntry(Request $request) {
|
|||
$newEntry->save();
|
||||
}
|
||||
|
||||
public static function selectEntries() {
|
||||
public static function selectEntries()
|
||||
{
|
||||
$entries = GuestbookEntry::orderBy('created_at', 'desc')->get();
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public static function importGuestbookEntry(array $data) {
|
||||
public static function importGuestbookEntry(array $data)
|
||||
{
|
||||
foreach ($data as $entry) {
|
||||
$dt = new \DateTime('@' . $entry['timestamp']);
|
||||
$newEntry = new GuestbookEntry;
|
||||
$newEntry = new GuestbookEntry();
|
||||
$newEntry->name = $entry['name'];
|
||||
$newEntry->ip = $entry['ip_address'];
|
||||
$newEntry->agent = $entry['agent'];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue