simplify readme

This commit is contained in:
jayson-temporas
2025-06-21 14:33:48 +08:00
parent 74cafa16a4
commit adcbfeebe0

View File

@@ -125,105 +125,6 @@ class User extends Authenticatable
}
```
### Using Bookmarks in Your Application
Once the trait is added, you can use the bookmark functionality in your application:
```php
// Get user's bookmarks
$user = auth()->user();
$bookmarks = $user->bookmarks;
// Get bookmark folders
$folders = $user->bookmarkFolders;
// Create a new bookmark
$bookmark = $user->createBookmark([
'name' => 'My Bookmark',
'url' => 'https://example.com',
'bookmark_folder_id' => $folder->id, // optional
]);
// Create a new folder
$folder = $user->createBookmarkFolder([
'name' => 'Work Bookmarks',
]);
// Get bookmarks in a specific folder
$workBookmarks = $user->bookmarksInFolder($folder);
// Check if user has bookmarks
if ($user->hasBookmarks()) {
// User has bookmarks
}
// Get bookmark counts
$bookmarkCount = $user->getBookmarksCount();
$folderCount = $user->getBookmarkFoldersCount();
```
### Available Methods
The `HasBookmarks` trait provides the following methods:
- `bookmarks()` - Get all bookmarks for the user
- `bookmarkFolders()` - Get all bookmark folders for the user
- `rootBookmarks()` - Get bookmarks not in any folder
- `createBookmarkFolder(array $attributes)` - Create a new bookmark folder
- `createBookmark(array $attributes)` - Create a new bookmark
- `bookmarksInFolder(BookmarkFolder $folder)` - Get bookmarks in a specific folder
- `bookmarksInFolderById(int $folderId)` - Get bookmarks in a folder by ID
- `hasBookmarks()` - Check if user has any bookmarks
- `hasBookmarkFolders()` - Check if user has any bookmark folders
- `getBookmarksCount()` - Get total bookmark count
- `getBookmarkFoldersCount()` - Get total folder count
## User Interface
### Adding Bookmarks
1. **Click the bookmark icon** in the Filament panel header
2. **Use keyboard shortcut** (default: `Cmd+Shift+B` on Mac or `Ctrl+Shift+B` on Windows/Linux)
3. The current page URL and title will be automatically captured
4. Enter a custom name (optional - defaults to page title)
5. Select or create a folder (optional)
6. Click "Save"
### Viewing Bookmarks
1. **Click the bookmark viewer icon** in the Filament panel header
2. Browse your bookmarks organized by folders
3. Use the search bar to filter bookmarks
4. Click on any bookmark to navigate to the saved URL
5. Hover over bookmarks to reveal the delete button
### Managing Bookmarks
- **Search**: Type in the search bar to filter bookmarks by name
- **Folders**: Click on folder headers to expand/collapse
- **Delete**: Hover over a bookmark and click the trash icon to delete
- **Navigation**: Click on any bookmark to navigate to the saved URL
## Database Schema
The package creates two tables:
### `bookmarks` table
- `id` - Primary key
- `user_id` - Foreign key to users table
- `name` - Bookmark name/title
- `bookmark_folder_id` - Foreign key to bookmark_folders table (nullable)
- `url` - The saved URL
- `created_at` - Creation timestamp
- `updated_at` - Last update timestamp
### `bookmark_folders` table
- `id` - Primary key
- `user_id` - Foreign key to users table
- `name` - Folder name
- `created_at` - Creation timestamp
- `updated_at` - Last update timestamp
## Customization
### Custom Icons