Big commit whatever
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[{compose,docker-compose}.{yml,yaml}]
|
||||
indent_size = 4
|
||||
@@ -0,0 +1,65 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
# PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
@@ -0,0 +1,11 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
@@ -0,0 +1,25 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
/.cursor/
|
||||
/.idea
|
||||
/.nova
|
||||
/.phpunit.cache
|
||||
/.vscode
|
||||
/.zed
|
||||
/auth.json
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
_ide_helper.php
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
@@ -0,0 +1 @@
|
||||
ignore-scripts=true
|
||||
@@ -0,0 +1 @@
|
||||
{"php":"8.5.5","version":"3.94.2","indent":" ","lineEnding":"\n","rules":{"nullable_type_declaration":true,"operator_linebreak":true,"ordered_types":{"null_adjustment":"always_last","sort_algorithm":"none"},"single_class_element_per_statement":true,"types_spaces":true,"array_indentation":true,"array_syntax":true,"attribute_block_no_spaces":true,"cast_spaces":true,"concat_space":{"spacing":"one"},"function_declaration":{"closure_fn_spacing":"none"},"method_argument_space":{"after_heredoc":true},"new_with_parentheses":{"anonymous_class":false},"single_line_empty_body":true,"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","const","const_import","do","else","elseif","enum","final","finally","for","foreach","function","function_import","if","insteadof","interface","match","named_argument","namespace","new","private","protected","public","readonly","static","switch","trait","try","type_colon","use","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"trailing_comma_in_multiline":{"after_heredoc":true},"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_anonymous_functions":false,"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"modifier_keywords":true,"no_blank_lines_after_class_opening":true,"no_extra_blank_lines":{"tokens":["use"]},"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"simple_to_complex_string_variable":true,"octal_notation":true,"clean_namespace":true,"no_unset_cast":true,"assign_null_coalescing_to_coalesce_equal":true,"normalize_index_brace":true,"heredoc_indentation":true,"no_whitespace_before_comma_in_array":{"after_heredoc":true},"list_syntax":true,"ternary_to_null_coalescing":true},"ruleCustomisationPolicyVersion":"null-policy","hashes":{"routes\/.conform.1860696.api.php":"ce95cf0201cb3f2d7ca74145dfe25775"}}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
|
||||
return (new Config())
|
||||
->setRiskyAllowed(false)
|
||||
->setRules([
|
||||
'@auto' => true
|
||||
])
|
||||
// 💡 by default, Fixer looks for `*.php` files excluding `./vendor/` - here, you can groom this config
|
||||
->setFinder(
|
||||
(new Finder())
|
||||
// 💡 root folder to check
|
||||
->in(__DIR__)
|
||||
// 💡 additional files, eg bin entry file
|
||||
// ->append([__DIR__.'/bin-entry-file'])
|
||||
// 💡 folders to exclude, if any
|
||||
// ->exclude([/* ... */])
|
||||
// 💡 path patterns to exclude, if any
|
||||
// ->notPath([/* ... */])
|
||||
// 💡 extra configs
|
||||
// ->ignoreDotFiles(false) // true by default in v3, false in v4 or future mode
|
||||
// ->ignoreVCS(true) // true by default
|
||||
)
|
||||
;
|
||||
@@ -0,0 +1,564 @@
|
||||
# Laravel Jukebox API - Complete Documentation
|
||||
|
||||
## Project Overview
|
||||
- **Framework**: Laravel 13.0
|
||||
- **PHP Version**: ^8.3
|
||||
- **Database**: MySQL (configured via Docker at 172.17.0.1:3306)
|
||||
- **Authentication**: Laravel Sanctum 4.0 (Token-based API authentication)
|
||||
- **Purpose**: Music streaming/management API with role-based access control
|
||||
|
||||
---
|
||||
|
||||
## 1. API ROUTES
|
||||
|
||||
### Location: `/routes/api.php`
|
||||
|
||||
#### Public Routes (No Authentication Required)
|
||||
```
|
||||
POST /register - User registration
|
||||
POST /login - User login
|
||||
```
|
||||
|
||||
#### Authenticated Routes (Requires Sanctum token)
|
||||
|
||||
**Auth Endpoints:**
|
||||
```
|
||||
POST /logout - Logout user
|
||||
GET /me - Get current user info
|
||||
```
|
||||
|
||||
**User Likes (Authenticated):**
|
||||
```
|
||||
GET /me/likes - Get user's liked tracks
|
||||
POST /tracks/{track}/like - Like a track
|
||||
DELETE /tracks/{track}/like - Unlike a track
|
||||
```
|
||||
|
||||
**Browse Routes (Read-only for authenticated users):**
|
||||
```
|
||||
GET /labels - List all labels
|
||||
GET /labels/{label} - Get label details
|
||||
GET /genres - List all genres
|
||||
GET /genres/{genre} - Get genre details
|
||||
GET /artists - List all artists
|
||||
GET /artists/{artist} - Get artist details
|
||||
GET /albums - List all albums
|
||||
GET /albums/{album} - Get album details
|
||||
GET /tracks - List all tracks
|
||||
GET /tracks/{track} - Get track details
|
||||
```
|
||||
|
||||
**Admin-Only Routes (Requires 'admin' role):**
|
||||
```
|
||||
POST /labels - Create label
|
||||
PUT /labels/{label} - Update label
|
||||
DELETE /labels/{label} - Delete label
|
||||
|
||||
POST /genres - Create genre
|
||||
PUT /genres/{genre} - Update genre
|
||||
DELETE /genres/{genre} - Delete genre
|
||||
|
||||
POST /artists - Create artist
|
||||
PUT /artists/{artist} - Update artist
|
||||
DELETE /artists/{artist} - Delete artist
|
||||
|
||||
POST /albums - Create album
|
||||
PUT /albums/{album} - Update album
|
||||
DELETE /albums/{album} - Delete album
|
||||
|
||||
POST /tracks - Create track
|
||||
PUT /tracks/{track} - Update track
|
||||
DELETE /tracks/{track} - Delete track
|
||||
|
||||
GET /users - List all users
|
||||
GET /users/{user} - Get user details
|
||||
PUT /users/{user} - Update user
|
||||
DELETE /users/{user} - Delete user
|
||||
```
|
||||
|
||||
#### Web Routes (`routes/web.php`)
|
||||
- Minimal: Single `GET /` returning welcome view (for blade/HTML views)
|
||||
|
||||
---
|
||||
|
||||
## 2. CONTROLLERS & METHODS
|
||||
|
||||
### AuthController (`app/Http/Controllers/AuthController.php`)
|
||||
**Methods:**
|
||||
- `register(Request $request): JsonResponse` - Handles user registration
|
||||
- Validates: name, email, password (min 8 chars, confirmed)
|
||||
- Creates user with default 'user' role
|
||||
- Returns token + user object
|
||||
- HTTP 201
|
||||
|
||||
- `login(Request $request): JsonResponse` - Handles user login
|
||||
- Validates: email, password
|
||||
- Returns token + user object if credentials valid
|
||||
- Throws ValidationException if invalid
|
||||
|
||||
- `logout(Request $request): JsonResponse` - Deletes current access token
|
||||
- Returns success message
|
||||
|
||||
- `me(Request $request): JsonResponse` - Returns current authenticated user
|
||||
- Loads user role relationship
|
||||
|
||||
---
|
||||
|
||||
### UserController (`app/Http/Controllers/UserController.php`)
|
||||
**Methods:**
|
||||
- `index(): JsonResponse` - List all users with roles
|
||||
- `show(User $user): JsonResponse` - Get single user with role
|
||||
- `update(Request $request, User $user): JsonResponse`
|
||||
- Validates: name, email (unique), password, role_id
|
||||
- Returns updated user with role
|
||||
- `destroy(User $user): JsonResponse` - Delete user
|
||||
- Returns HTTP 204
|
||||
|
||||
---
|
||||
|
||||
### ArtistController (`app/Http/Controllers/ArtistController.php`)
|
||||
**Methods:**
|
||||
- `index(): JsonResponse` - List artists with label relationship
|
||||
- `show(Artist $artist): JsonResponse` - Get artist with label, tracks, genres
|
||||
- `store(Request $request): JsonResponse`
|
||||
- Validates: name, cover_path (nullable), release_date (nullable), label_id, duration
|
||||
- Returns HTTP 201
|
||||
- `update(Request $request, Artist $artist): JsonResponse` - Update artist
|
||||
- `destroy(Artist $artist): JsonResponse` - Delete artist
|
||||
|
||||
---
|
||||
|
||||
### AlbumController (`app/Http/Controllers/AlbumController.php`)
|
||||
**Methods:**
|
||||
- `index(): JsonResponse` - List albums with labels
|
||||
- `show(Album $album): JsonResponse` - Get album with label, tracks, artists, genres
|
||||
- `store(Request $request): JsonResponse`
|
||||
- Validates: title, cover_path, release_date, duration_seconds, type (enum: album|single|ep), label_id
|
||||
- Returns HTTP 201
|
||||
- `update(Request $request, Album $album): JsonResponse` - Update album
|
||||
- `destroy(Album $album): JsonResponse` - Delete album
|
||||
|
||||
---
|
||||
|
||||
### TrackController (`app/Http/Controllers/TrackController.php`)
|
||||
**Methods:**
|
||||
- `index(): JsonResponse` - List tracks with album, artists, genres
|
||||
- `show(Track $track): JsonResponse` - Get track with album.label, artists, genres
|
||||
- `store(Request $request): JsonResponse`
|
||||
- Validates: title, file_path, duration_seconds (nullable), album_id (nullable), artist_ids (array), genre_ids (array)
|
||||
- Syncs artist and genre relationships
|
||||
- Returns HTTP 201
|
||||
- `update(Request $request, Track $track): JsonResponse`
|
||||
- Syncs artist and genre relationships
|
||||
- `destroy(Track $track): JsonResponse` - Delete track
|
||||
|
||||
---
|
||||
|
||||
### LikeController (`app/Http/Controllers/LikeController.php`)
|
||||
**Methods:**
|
||||
- `like(Request $request, Track $track): JsonResponse`
|
||||
- Uses `syncWithoutDetaching()` to add like without removing existing ones
|
||||
- `unlike(Request $request, Track $track): JsonResponse`
|
||||
- Uses `detach()` to remove like
|
||||
- `index(Request $request): JsonResponse`
|
||||
- Returns user's liked tracks with album, artists, genres relationships
|
||||
|
||||
---
|
||||
|
||||
### GenreController (`app/Http/Controllers/GenreController.php`)
|
||||
**Methods:**
|
||||
- `index(): JsonResponse` - List all genres
|
||||
- `show(Genre $genre): JsonResponse` - Get single genre
|
||||
- `store(Request $request): JsonResponse` - Create genre (validates: name, max 100 chars)
|
||||
- `update(Request $request, Genre $genre): JsonResponse` - Update genre
|
||||
- `destroy(Genre $genre): JsonResponse` - Delete genre
|
||||
|
||||
---
|
||||
|
||||
### LabelController (`app/Http/Controllers/LabelController.php`)
|
||||
**Methods:**
|
||||
- `index(): JsonResponse` - List all labels
|
||||
- `show(Label $label): JsonResponse` - Get single label
|
||||
- `store(Request $request): JsonResponse` - Create label (validates: name, max 100 chars)
|
||||
- `update(Request $request, Label $label): JsonResponse` - Update label
|
||||
- `destroy(Label $label): JsonResponse` - Delete label
|
||||
|
||||
---
|
||||
|
||||
## 3. MODELS & RELATIONSHIPS
|
||||
|
||||
### User Model
|
||||
**Attributes:** id, name, email, password (hashed), role_id, timestamps
|
||||
**Fillable:** name, email, password, role_id
|
||||
**Hidden:** password, remember_token
|
||||
**Traits:** HasApiTokens, HasFactory, Notifiable
|
||||
|
||||
**Relationships:**
|
||||
- `role()`: BelongsTo(Role) - User's role
|
||||
- `likes()`: BelongsToMany(Track, 'likes') - Tracks user has liked
|
||||
|
||||
---
|
||||
|
||||
### Role Model
|
||||
**Attributes:** id, name, timestamps
|
||||
**Fillable:** name
|
||||
|
||||
**Relationships:**
|
||||
- `users()`: HasMany(User) - Users with this role
|
||||
|
||||
---
|
||||
|
||||
### Artist Model
|
||||
**Attributes:** id, name, cover_path, release_date, label_id, duration, timestamps
|
||||
**Fillable:** name, cover_path, release_date, label_id, duration
|
||||
|
||||
**Relationships:**
|
||||
- `label()`: BelongsTo(Label) - Artist's label
|
||||
- `tracks()`: BelongsToMany(Track, 'artist_track') - All tracks by artist
|
||||
|
||||
---
|
||||
|
||||
### Album Model
|
||||
**Attributes:** id, title, cover_path, release_date, duration_seconds, type (enum), label_id, timestamps
|
||||
**Fillable:** title, cover_path, release_date, duration_seconds, type, label_id
|
||||
|
||||
**Relationships:**
|
||||
- `label()`: BelongsTo(Label) - Album's label
|
||||
- `tracks()`: HasMany(Track) - All tracks in album
|
||||
|
||||
---
|
||||
|
||||
### Track Model
|
||||
**Attributes:** id, title, file_path, duration_seconds, album_id, timestamps
|
||||
**Fillable:** title, file_path, duration_seconds, album_id
|
||||
|
||||
**Relationships:**
|
||||
- `album()`: BelongsTo(Album) - Album containing track
|
||||
- `artists()`: BelongsToMany(Artist, 'artist_track') - Contributing artists
|
||||
- `genres()`: BelongsToMany(Genre, 'track_genre') - Track genres
|
||||
- `likedBy()`: BelongsToMany(User, 'likes') - Users who liked track
|
||||
|
||||
---
|
||||
|
||||
### Genre Model
|
||||
**Attributes:** id, name, timestamps
|
||||
**Fillable:** name
|
||||
|
||||
**Relationships:**
|
||||
- `tracks()`: BelongsToMany(Track, 'track_genre') - Tracks in genre
|
||||
|
||||
---
|
||||
|
||||
### Label Model
|
||||
**Attributes:** id, name, timestamps
|
||||
**Fillable:** name
|
||||
|
||||
**Relationships:**
|
||||
- `artists()`: HasMany(Artist) - Artists on label
|
||||
- `albums()`: HasMany(Album) - Albums on label
|
||||
|
||||
---
|
||||
|
||||
## 4. DATABASE SCHEMA & MIGRATIONS
|
||||
|
||||
### Tables Created (in order)
|
||||
|
||||
**1. roles**
|
||||
- id (PRIMARY)
|
||||
- name (VARCHAR)
|
||||
- timestamps
|
||||
|
||||
**2. genres**
|
||||
- id (PRIMARY)
|
||||
- name (VARCHAR 100)
|
||||
- timestamps
|
||||
|
||||
**3. labels**
|
||||
- id (PRIMARY)
|
||||
- name (VARCHAR 100)
|
||||
- timestamps
|
||||
|
||||
**4. users**
|
||||
- id (PRIMARY)
|
||||
- name (VARCHAR)
|
||||
- email (VARCHAR)
|
||||
- password (VARCHAR)
|
||||
- role_id (FOREIGN KEY → roles.id)
|
||||
- timestamps
|
||||
|
||||
**5. artists**
|
||||
- id (PRIMARY)
|
||||
- name (VARCHAR 255)
|
||||
- cover_path (VARCHAR 255, nullable)
|
||||
- release_date (DATETIME, nullable)
|
||||
- label_id (FOREIGN KEY → labels.id, nullable)
|
||||
- duration (INTEGER, nullable)
|
||||
- timestamps
|
||||
|
||||
**6. albums**
|
||||
- id (PRIMARY)
|
||||
- title (VARCHAR 255)
|
||||
- cover_path (VARCHAR 255, nullable)
|
||||
- release_date (DATETIME, nullable)
|
||||
- duration_seconds (INTEGER, nullable)
|
||||
- type (ENUM: 'album', 'single', 'ep', default: 'album')
|
||||
- label_id (FOREIGN KEY → labels.id, nullable)
|
||||
- timestamps
|
||||
|
||||
**7. tracks**
|
||||
- id (PRIMARY)
|
||||
- title (VARCHAR 255)
|
||||
- file_path (VARCHAR 255)
|
||||
- duration_seconds (INTEGER, nullable)
|
||||
- album_id (FOREIGN KEY → albums.id, nullable)
|
||||
- timestamps
|
||||
|
||||
**8. artist_track** (pivot table)
|
||||
- artist_id (FOREIGN KEY → artists.id)
|
||||
- track_id (FOREIGN KEY → tracks.id)
|
||||
- PRIMARY KEY: (artist_id, track_id)
|
||||
- timestamps
|
||||
|
||||
**9. track_genre** (pivot table)
|
||||
- track_id (FOREIGN KEY → tracks.id)
|
||||
- genre_id (FOREIGN KEY → genres.id)
|
||||
- PRIMARY KEY: (track_id, genre_id)
|
||||
- timestamps
|
||||
|
||||
**10. likes** (pivot table)
|
||||
- user_id (FOREIGN KEY → users.id)
|
||||
- track_id (FOREIGN KEY → tracks.id)
|
||||
- PRIMARY KEY: (user_id, track_id)
|
||||
- timestamps
|
||||
|
||||
**11. personal_access_tokens** (Sanctum)
|
||||
- id (PRIMARY)
|
||||
- tokenable_id, tokenable_type (polymorphic)
|
||||
- name (TEXT)
|
||||
- token (VARCHAR 64, UNIQUE)
|
||||
- abilities (TEXT, nullable)
|
||||
- last_used_at (TIMESTAMP, nullable)
|
||||
- expires_at (TIMESTAMP, nullable, indexed)
|
||||
- timestamps
|
||||
|
||||
---
|
||||
|
||||
## 5. AUTHENTICATION & AUTHORIZATION
|
||||
|
||||
### Sanctum Configuration (`config/sanctum.php`)
|
||||
|
||||
**Stateful Domains:**
|
||||
- localhost, localhost:3000, 127.0.0.1, 127.0.0.1:8000, ::1
|
||||
- Plus current application URL
|
||||
|
||||
**Guard:** web (session guard, though API uses bearer tokens)
|
||||
|
||||
**Expiration:** null (tokens don't expire automatically)
|
||||
|
||||
**Token Prefix:** env('SANCTUM_TOKEN_PREFIX', '')
|
||||
|
||||
**Middleware:**
|
||||
- authenticate_session: Laravel\Sanctum\Http\Middleware\AuthenticateSession
|
||||
- encrypt_cookies: Illuminate\Cookie\Middleware\EncryptCookies
|
||||
- validate_csrf_token: Illuminate\Foundation\Http\Middleware\ValidateCsrfToken
|
||||
|
||||
### Auth Configuration (`config/auth.php`)
|
||||
|
||||
**Default Guard:** web (session-based)
|
||||
|
||||
**User Provider:** Eloquent (uses App\Models\User)
|
||||
|
||||
**Password Broker:** users (uses users table)
|
||||
|
||||
**Token Expiry:** 60 minutes
|
||||
|
||||
### Custom Middleware
|
||||
|
||||
**EnsureAdmin** (`app/Http/Middleware/EnsureAdmin.php`)
|
||||
- Checks if user's role name is 'admin'
|
||||
- Returns 403 Forbidden if not admin
|
||||
- Applied to routes group via 'admin' alias in `bootstrap/app.php`
|
||||
|
||||
---
|
||||
|
||||
## 6. SEEDERS & FACTORIES
|
||||
|
||||
### DatabaseSeeder (`database/seeders/DatabaseSeeder.php`)
|
||||
Currently creates a single test user:
|
||||
```
|
||||
Name: Test User
|
||||
Email: test@example.com
|
||||
Password: Uses UserFactory default
|
||||
```
|
||||
|
||||
The seeder is commented to create 10 users but currently just creates 1.
|
||||
|
||||
### UserFactory (`database/factories/UserFactory.php`)
|
||||
**Attributes Generated:**
|
||||
- name: fake()->name()
|
||||
- email: fake()->unique()->safeEmail()
|
||||
- email_verified_at: now()
|
||||
- password: Hash::make('password')
|
||||
- remember_token: Str::random(10)
|
||||
|
||||
**Methods:**
|
||||
- `unverified()`: Sets email_verified_at to null
|
||||
|
||||
**Note:** No factory exists for other models (Artist, Album, Track, Genre, Label)
|
||||
|
||||
---
|
||||
|
||||
## 7. CORS CONFIGURATION
|
||||
|
||||
**Status:** No explicit CORS configuration found
|
||||
|
||||
**Implications:**
|
||||
- No `config/cors.php` file
|
||||
- Sanctum handles CORS implicitly via stateful domains configuration
|
||||
- Likely relying on Laravel default CORS handling or missing CORS setup
|
||||
- Frontend on localhost:3000 should work (listed in stateful domains)
|
||||
|
||||
**Recommendation:** May need explicit CORS middleware for production cross-origin requests
|
||||
|
||||
---
|
||||
|
||||
## 8. RESOURCES & TRANSFORMERS
|
||||
|
||||
**Status:** No JSON:API Resources or Transformers found
|
||||
|
||||
**Current Approach:**
|
||||
- Direct Eloquent model casting to JSON
|
||||
- Raw `response()->json()` returns from controllers
|
||||
- Relationships loaded via `load()` and `with()` methods
|
||||
- No API resource classes (Laravel Resource classes) implemented
|
||||
|
||||
**Data Transformation:**
|
||||
- Manual eager loading in controllers
|
||||
- Example: `$artist->load(['label', 'tracks.album', 'tracks.genres'])`
|
||||
|
||||
---
|
||||
|
||||
## 9. ENVIRONMENT CONFIGURATION
|
||||
|
||||
### .env (Development)
|
||||
```
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=172.17.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=jukebox
|
||||
DB_USERNAME=jukebox_admin
|
||||
DB_PASSWORD=Super
|
||||
|
||||
SESSION_DRIVER=database
|
||||
CACHE_STORE=database
|
||||
QUEUE_CONNECTION=database
|
||||
```
|
||||
|
||||
### Key Settings
|
||||
- Debug mode enabled (local)
|
||||
- MySQL via Docker (172.17.0.1)
|
||||
- Database-backed sessions
|
||||
- Database-backed queue
|
||||
- Database-backed cache
|
||||
|
||||
---
|
||||
|
||||
## 10. DEPENDENCIES
|
||||
|
||||
**Core:**
|
||||
- laravel/framework: ^13.0
|
||||
- laravel/sanctum: ^4.0
|
||||
- laravel/tinker: ^3.0
|
||||
|
||||
**Dev:**
|
||||
- fakerphp/faker: ^1.23
|
||||
- laravel/pail: ^1.2.5
|
||||
- laravel/pint: ^1.27
|
||||
- mockery/mockery: ^1.6
|
||||
- nunomaduro/collision: ^8.6
|
||||
- phpunit/phpunit: ^12.5.12
|
||||
|
||||
---
|
||||
|
||||
## 11. KEY OBSERVATIONS & NOTES
|
||||
|
||||
### Strengths
|
||||
1. **Clean Role-Based Architecture** - Admin/User separation via middleware
|
||||
2. **Proper Eloquent Relationships** - All pivot tables correctly implemented
|
||||
3. **Token-Based Auth** - Sanctum for stateless API authentication
|
||||
4. **Comprehensive Data Model** - Well-structured music catalog schema
|
||||
|
||||
### Areas for Enhancement
|
||||
1. **No Resources/Transformers** - Consider Laravel API Resources for consistent responses
|
||||
2. **No CORS Config** - Explicit CORS setup recommended for production
|
||||
3. **Limited Factories** - Only UserFactory; others could enable better testing
|
||||
4. **No API Documentation** - Consider OpenAPI/Swagger docs
|
||||
5. **No Request DTOs** - Could use Form Requests for centralized validation
|
||||
6. **No Response Standardization** - No consistent error/success response format
|
||||
7. **No Pagination** - List endpoints return all results (performance concern)
|
||||
8. **No Query Filtering** - No search/filter capabilities on GET endpoints
|
||||
9. **No Rate Limiting** - No API rate limiting configured
|
||||
10. **Minimal Seeding** - Only test user; could seed sample data
|
||||
|
||||
### Security Considerations
|
||||
1. Password hashing properly handled via Laravel
|
||||
2. CSRF protection configured (though API uses tokens)
|
||||
3. Access control via admin middleware is solid
|
||||
4. Foreign key constraints prevent orphaned records
|
||||
5. Role-based authorization working correctly
|
||||
|
||||
### API Response Format
|
||||
Current format (no wrapper):
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Track Name",
|
||||
"duration_seconds": 240,
|
||||
"created_at": "2026-04-23T...",
|
||||
"updated_at": "2026-04-23T..."
|
||||
}
|
||||
```
|
||||
|
||||
Could benefit from standardized wrapper:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": { ... },
|
||||
"message": "Success"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 12. TESTING STRUCTURE
|
||||
|
||||
**Test Framework:** PHPUnit 12.5.12
|
||||
|
||||
**Test Directories:**
|
||||
- `tests/Feature/` - Feature tests
|
||||
- `tests/Unit/` - Unit tests
|
||||
- `tests/TestCase.php` - Base test class
|
||||
|
||||
**Example Tests:** ExampleTest.php files (placeholder)
|
||||
|
||||
**No comprehensive tests currently implemented**
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
This is a **music streaming/library API** built with Laravel 13, featuring:
|
||||
- ✅ User registration & login with Sanctum tokens
|
||||
- ✅ Role-based access control (admin/user)
|
||||
- ✅ Full CRUD for Artists, Albums, Tracks, Genres, Labels
|
||||
- ✅ User favorites/likes system
|
||||
- ✅ Proper database schema with relationships
|
||||
- ⚠️ Minimal documentation, testing, and optimization
|
||||
- ⚠️ Missing common API best practices
|
||||
|
||||
Ready for development and enhancement with proper testing, documentation, and optimization work.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,242 @@
|
||||
# Laravel Jukebox API - Quick Reference
|
||||
|
||||
## 🔐 Authentication
|
||||
- **Method**: Laravel Sanctum (Bearer Token)
|
||||
- **Register**: `POST /register` - Creates user with 'user' role
|
||||
- **Login**: `POST /login` - Returns Bearer token
|
||||
- **Logout**: `POST /logout` - Deletes token
|
||||
- **Me**: `GET /me` - Current user info
|
||||
|
||||
## 📊 Database
|
||||
```
|
||||
Roles (id, name)
|
||||
Users (id, name, email, password, role_id)
|
||||
├─ belongs_to: Role
|
||||
└─ belongs_to_many: Track (likes table)
|
||||
|
||||
Labels (id, name)
|
||||
├─ has_many: Artist
|
||||
└─ has_many: Album
|
||||
|
||||
Genres (id, name)
|
||||
└─ belongs_to_many: Track (track_genre table)
|
||||
|
||||
Artists (id, name, cover_path, release_date, label_id, duration)
|
||||
├─ belongs_to: Label
|
||||
└─ belongs_to_many: Track (artist_track table)
|
||||
|
||||
Albums (id, title, cover_path, release_date, duration_seconds, type, label_id)
|
||||
├─ belongs_to: Label
|
||||
└─ has_many: Track
|
||||
|
||||
Tracks (id, title, file_path, duration_seconds, album_id)
|
||||
├─ belongs_to: Album
|
||||
├─ belongs_to_many: Artist (artist_track table)
|
||||
├─ belongs_to_many: Genre (track_genre table)
|
||||
└─ belongs_to_many: User (likes table)
|
||||
```
|
||||
|
||||
## 🔓 Public Endpoints
|
||||
```
|
||||
POST /register
|
||||
POST /login
|
||||
```
|
||||
|
||||
## 🔒 Authenticated Endpoints (All require Bearer token)
|
||||
|
||||
### Account Management
|
||||
```
|
||||
POST /logout
|
||||
GET /me
|
||||
PUT /me (User update - not implemented yet)
|
||||
```
|
||||
|
||||
### User Likes
|
||||
```
|
||||
GET /me/likes - Get liked tracks
|
||||
POST /tracks/{id}/like - Like a track
|
||||
DELETE /tracks/{id}/like - Unlike a track
|
||||
```
|
||||
|
||||
### Browse (Read-only)
|
||||
```
|
||||
GET /labels
|
||||
GET /labels/{id}
|
||||
GET /genres
|
||||
GET /genres/{id}
|
||||
GET /artists
|
||||
GET /artists/{id} (includes: label, tracks.album, tracks.genres)
|
||||
GET /albums
|
||||
GET /albums/{id} (includes: label, tracks.artists, tracks.genres)
|
||||
GET /tracks
|
||||
GET /tracks/{id} (includes: album.label, artists, genres)
|
||||
```
|
||||
|
||||
## 👑 Admin-Only Endpoints (role_id where role.name='admin')
|
||||
|
||||
### Create/Update/Delete
|
||||
```
|
||||
POST /labels POST /genres POST /artists
|
||||
PUT /labels/{id} PUT /genres/{id} PUT /artists/{id}
|
||||
DELETE /labels/{id} DELETE /genres/{id} DELETE /artists/{id}
|
||||
|
||||
POST /albums POST /tracks
|
||||
PUT /albums/{id} PUT /tracks/{id}
|
||||
DELETE /albums/{id} DELETE /tracks/{id}
|
||||
|
||||
POST /users GET /users
|
||||
PUT /users/{id} GET /users/{id}
|
||||
DELETE /users/{id}
|
||||
```
|
||||
|
||||
## 📝 Controllers
|
||||
| Controller | Methods | Purpose |
|
||||
|-----------|---------|---------|
|
||||
| AuthController | register, login, logout, me | User authentication |
|
||||
| UserController | index, show, update, destroy | User management (admin) |
|
||||
| ArtistController | index, show, store, update, destroy | Artist CRUD |
|
||||
| AlbumController | index, show, store, update, destroy | Album CRUD |
|
||||
| TrackController | index, show, store, update, destroy | Track CRUD with pivot syncing |
|
||||
| GenreController | index, show, store, update, destroy | Genre CRUD |
|
||||
| LabelController | index, show, store, update, destroy | Label CRUD |
|
||||
| LikeController | index, like, unlike | User favorites |
|
||||
|
||||
## 🛡️ Middleware
|
||||
- `auth:sanctum` - All authenticated routes
|
||||
- `admin` - Admin-only routes (checks role.name === 'admin')
|
||||
|
||||
## 🔑 Key Validation Rules
|
||||
|
||||
### Registration
|
||||
- name: required, string, max:255
|
||||
- email: required, email, unique:users
|
||||
- password: required, string, min:8, confirmed
|
||||
|
||||
### Artist/Album/Track Creation
|
||||
- Supports partial nullable fields
|
||||
- Artist: name (required), cover_path, release_date, label_id, duration
|
||||
- Album: title (required), cover_path, release_date, duration_seconds, type, label_id
|
||||
- Track: title (required), file_path (required), duration_seconds, album_id, artist_ids[], genre_ids[]
|
||||
|
||||
## ⚠️ Notable Limitations
|
||||
- ❌ No pagination on list endpoints (returns all records)
|
||||
- ❌ No search/filtering capabilities
|
||||
- ❌ No rate limiting
|
||||
- ❌ No API resources/transformers (direct model JSON)
|
||||
- ❌ No CORS config file (relying on Sanctum defaults)
|
||||
- ❌ No endpoint documentation/OpenAPI spec
|
||||
- ❌ Minimal test coverage
|
||||
- ❌ Only UserFactory (no factories for other models)
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
```bash
|
||||
# Register
|
||||
curl -X POST http://localhost/api/register \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"User","email":"user@example.com","password":"password123","password_confirmation":"password123"}'
|
||||
|
||||
# Response
|
||||
{
|
||||
"token": "1|abc123...",
|
||||
"user": {
|
||||
"id": 1,
|
||||
"name": "User",
|
||||
"email": "user@example.com",
|
||||
"role": {"id": 1, "name": "user"}
|
||||
}
|
||||
}
|
||||
|
||||
# Use token in subsequent requests
|
||||
curl -X GET http://localhost/api/me \
|
||||
-H "Authorization: Bearer 1|abc123..."
|
||||
|
||||
# Like a track
|
||||
curl -X POST http://localhost/api/tracks/1/like \
|
||||
-H "Authorization: Bearer 1|abc123..."
|
||||
|
||||
# Get liked tracks
|
||||
curl -X GET http://localhost/api/me/likes \
|
||||
-H "Authorization: Bearer 1|abc123..."
|
||||
```
|
||||
|
||||
## 📁 Directory Structure
|
||||
```
|
||||
/app
|
||||
/Http
|
||||
/Controllers (8 controllers)
|
||||
/Middleware (EnsureAdmin)
|
||||
/Models (7 models)
|
||||
/Providers
|
||||
/routes
|
||||
/api.php (main API routes)
|
||||
/web.php (minimal web routes)
|
||||
/database
|
||||
/migrations (11 migrations)
|
||||
/seeders (DatabaseSeeder - creates 1 test user)
|
||||
/factories (UserFactory only)
|
||||
/config
|
||||
/sanctum.php (token auth config)
|
||||
/auth.php (authentication guards)
|
||||
```
|
||||
|
||||
## 🔄 Response Formats
|
||||
|
||||
### Success (Single Resource)
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Artist Name",
|
||||
"created_at": "2026-04-21T...",
|
||||
"updated_at": "2026-04-21T..."
|
||||
}
|
||||
```
|
||||
|
||||
### Success (List)
|
||||
```json
|
||||
[
|
||||
{ "id": 1, "name": "Item 1" },
|
||||
{ "id": 2, "name": "Item 2" }
|
||||
]
|
||||
```
|
||||
|
||||
### Delete (204 No Content)
|
||||
```
|
||||
No body
|
||||
```
|
||||
|
||||
### Error (ValidationException)
|
||||
```json
|
||||
{
|
||||
"message": "The given data was invalid.",
|
||||
"errors": {
|
||||
"email": ["The email has already been taken."]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Error (403 Forbidden - Admin Only)
|
||||
```json
|
||||
{
|
||||
"message": "Forbidden."
|
||||
}
|
||||
```
|
||||
|
||||
## 🔗 Relationship Eager Loading (Controllers)
|
||||
- Artist show: `with(['label', 'tracks.album', 'tracks.genres'])`
|
||||
- Album show: `with(['label', 'tracks.artists', 'tracks.genres'])`
|
||||
- Track show: `with(['album.label', 'artists', 'genres'])`
|
||||
- Track index: `with(['album', 'artists', 'genres'])`
|
||||
- Likes index: `with(['album', 'artists', 'genres'])`
|
||||
|
||||
## 🗄️ Database Connection
|
||||
- Type: MySQL
|
||||
- Host: 172.17.0.1 (Docker)
|
||||
- Port: 3306
|
||||
- Database: jukebox
|
||||
- User: jukebox_admin
|
||||
- Password: Super
|
||||
|
||||
---
|
||||
|
||||
**Full documentation available in: `/API_DOCUMENTATION.md`**
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
|
||||
In addition, [Laracasts](https://laracasts.com) contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
You can also watch bite-sized lessons with real-world projects on [Laravel Learn](https://laravel.com/learn), where you will be guided through building a Laravel application from scratch while learning PHP fundamentals.
|
||||
|
||||
## Agentic Development
|
||||
|
||||
Laravel's predictable structure and conventions make it ideal for AI coding agents like Claude Code, Cursor, and GitHub Copilot. Install [Laravel Boost](https://laravel.com/docs/ai) to supercharge your AI workflow:
|
||||
|
||||
```bash
|
||||
composer require laravel/boost --dev
|
||||
|
||||
php artisan boost:install
|
||||
```
|
||||
|
||||
Boost provides your agent 15+ tools and skills that help agents build Laravel applications while following best practices.
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
@@ -0,0 +1,393 @@
|
||||
# Laravel Jukebox API - Documentation Index
|
||||
|
||||
Welcome! This directory contains comprehensive documentation for the Laravel Jukebox API.
|
||||
|
||||
## 📚 Documentation Files
|
||||
|
||||
### 1. **API_QUICK_REFERENCE.md** ⭐ START HERE
|
||||
**Best for:** Quick lookups, endpoint overview, getting oriented
|
||||
|
||||
- Database relationship diagram
|
||||
- Complete endpoint summary (40+ routes)
|
||||
- Authentication methods
|
||||
- Validation rules
|
||||
- Known limitations
|
||||
- Quick start examples with curl
|
||||
|
||||
**Read time:** ~5 minutes
|
||||
|
||||
---
|
||||
|
||||
### 2. **API_EXAMPLES.md**
|
||||
**Best for:** Understanding request/response formats, testing endpoints
|
||||
|
||||
- Real request/response examples for every operation
|
||||
- All CRUD operations demonstrated
|
||||
- Error response samples
|
||||
- HTTP status codes reference
|
||||
- Headers and authentication examples
|
||||
- cURL command examples
|
||||
|
||||
**Read time:** ~10 minutes
|
||||
|
||||
---
|
||||
|
||||
### 3. **API_DOCUMENTATION.md**
|
||||
**Best for:** Complete technical reference, deep understanding
|
||||
|
||||
- All API routes with descriptions
|
||||
- All 8 controllers and 31 methods detailed
|
||||
- All 7 models with relationships
|
||||
- Database schema (11 tables) with column details
|
||||
- Authentication & authorization explained
|
||||
- Configuration details
|
||||
- Seeders & factories documentation
|
||||
- CORS configuration status
|
||||
- Key observations & recommendations
|
||||
|
||||
**Read time:** ~20 minutes
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Step 1: Register a user
|
||||
```bash
|
||||
curl -X POST http://localhost/api/register \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"name": "Your Name",
|
||||
"email": "user@example.com",
|
||||
"password": "password123",
|
||||
"password_confirmation": "password123"
|
||||
}'
|
||||
```
|
||||
|
||||
### Step 2: Get your token
|
||||
The response contains a `token` field. Copy it.
|
||||
|
||||
### Step 3: Use the token
|
||||
```bash
|
||||
curl -X GET http://localhost/api/me \
|
||||
-H "Authorization: Bearer YOUR_TOKEN_HERE"
|
||||
```
|
||||
|
||||
### Step 4: Explore
|
||||
Browse the API_EXAMPLES.md for more operations.
|
||||
|
||||
---
|
||||
|
||||
## 📊 API Structure
|
||||
|
||||
```
|
||||
PUBLIC ENDPOINTS (2)
|
||||
├── POST /register
|
||||
└── POST /login
|
||||
|
||||
AUTHENTICATED ENDPOINTS (37+)
|
||||
├── Account Management
|
||||
│ ├── POST /logout
|
||||
│ └── GET /me
|
||||
├── User Likes
|
||||
│ ├── GET /me/likes
|
||||
│ ├── POST /tracks/{id}/like
|
||||
│ └── DELETE /tracks/{id}/like
|
||||
└── Browse (Read-only)
|
||||
├── Labels (GET /labels, /labels/{id})
|
||||
├── Genres (GET /genres, /genres/{id})
|
||||
├── Artists (GET /artists, /artists/{id})
|
||||
├── Albums (GET /albums, /albums/{id})
|
||||
└── Tracks (GET /tracks, /tracks/{id})
|
||||
|
||||
ADMIN-ONLY ENDPOINTS (24)
|
||||
├── Create/Update/Delete: Labels, Genres, Artists, Albums, Tracks
|
||||
└── User Management: List, View, Update, Delete Users
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Authentication
|
||||
|
||||
This API uses **Laravel Sanctum Bearer Tokens**.
|
||||
|
||||
1. Register or login to get a token
|
||||
2. Include token in all requests: `Authorization: Bearer {token}`
|
||||
3. Tokens stored in `personal_access_tokens` table
|
||||
4. No automatic expiration (infinite lifetime)
|
||||
|
||||
---
|
||||
|
||||
## 👥 Authorization
|
||||
|
||||
Two roles exist:
|
||||
- **user** (default) - Can browse content and manage likes
|
||||
- **admin** - Can create/update/delete content and manage users
|
||||
|
||||
Checked via custom `EnsureAdmin` middleware.
|
||||
|
||||
---
|
||||
|
||||
## 📁 Directory Map
|
||||
|
||||
```
|
||||
/app
|
||||
/Http/Controllers - 8 controllers with 31 methods
|
||||
/Http/Middleware - EnsureAdmin (role checking)
|
||||
/Models - 7 Eloquent models with relationships
|
||||
|
||||
/routes
|
||||
/api.php - All 40+ API routes defined here
|
||||
/web.php - Minimal web routes
|
||||
|
||||
/database
|
||||
/migrations - 11 migration files (ordered)
|
||||
/seeders - DatabaseSeeder (creates test user)
|
||||
/factories - UserFactory (only one)
|
||||
|
||||
/config
|
||||
/sanctum.php - Token auth configuration
|
||||
/auth.php - Authentication guards setup
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 Database Schema Overview
|
||||
|
||||
### Core Tables
|
||||
- **roles** - User roles (admin, user)
|
||||
- **users** - User accounts
|
||||
- **labels** - Record labels
|
||||
- **genres** - Music genres
|
||||
|
||||
### Music Catalog
|
||||
- **artists** - Musicians/bands
|
||||
- **albums** - Albums/EPs/singles
|
||||
- **tracks** - Individual songs
|
||||
|
||||
### Relationships
|
||||
- **artist_track** - Many-to-many (artists can have many tracks)
|
||||
- **track_genre** - Many-to-many (tracks can have many genres)
|
||||
- **likes** - Many-to-many (users can like many tracks)
|
||||
|
||||
### Authentication
|
||||
- **personal_access_tokens** - Sanctum tokens for API authentication
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Data Relationships
|
||||
|
||||
```
|
||||
User
|
||||
├── role (1-to-many)
|
||||
└── likes (many-to-many: Track)
|
||||
|
||||
Artist
|
||||
├── label (1-to-many)
|
||||
└── tracks (many-to-many)
|
||||
|
||||
Album
|
||||
├── label (1-to-many)
|
||||
└── tracks (1-to-many)
|
||||
|
||||
Track
|
||||
├── album (1-to-many)
|
||||
├── artists (many-to-many)
|
||||
├── genres (many-to-many)
|
||||
└── likedBy users (many-to-many)
|
||||
|
||||
Genre
|
||||
└── tracks (many-to-many)
|
||||
|
||||
Label
|
||||
├── artists (1-to-many)
|
||||
└── albums (1-to-many)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Current Limitations
|
||||
|
||||
- ❌ No pagination on list endpoints
|
||||
- ❌ No search/filtering capability
|
||||
- ❌ No rate limiting
|
||||
- ❌ No API documentation tool (Swagger/OpenAPI)
|
||||
- ❌ No automatic response wrapping
|
||||
- ❌ No audit logging
|
||||
- ❌ Limited test coverage
|
||||
|
||||
See API_DOCUMENTATION.md §11 for detailed observations.
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Key Technologies
|
||||
|
||||
- **Framework:** Laravel 13.0
|
||||
- **PHP:** 8.3+
|
||||
- **Database:** MySQL (Docker at 172.17.0.1:3306)
|
||||
- **Authentication:** Laravel Sanctum 4.0
|
||||
- **ORM:** Eloquent
|
||||
- **Testing:** PHPUnit (12.5.12)
|
||||
|
||||
---
|
||||
|
||||
## 📝 Response Format
|
||||
|
||||
All responses are JSON.
|
||||
|
||||
**Success (single resource):**
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Example",
|
||||
"created_at": "2026-05-07T...",
|
||||
"updated_at": "2026-05-07T..."
|
||||
}
|
||||
```
|
||||
|
||||
**Success (list):**
|
||||
```json
|
||||
[
|
||||
{ "id": 1, "name": "Item 1" },
|
||||
{ "id": 2, "name": "Item 2" }
|
||||
]
|
||||
```
|
||||
|
||||
**Error:**
|
||||
```json
|
||||
{
|
||||
"message": "Error description",
|
||||
"errors": {
|
||||
"field": ["Validation error message"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Testing Accounts
|
||||
|
||||
**Test User (from DatabaseSeeder):**
|
||||
- Email: `test@example.com`
|
||||
- Password: `password`
|
||||
- Role: user
|
||||
|
||||
Use these credentials to login and get a token.
|
||||
|
||||
---
|
||||
|
||||
## 📞 Common Tasks
|
||||
|
||||
### Browse Music
|
||||
```
|
||||
GET /api/artists
|
||||
GET /api/albums
|
||||
GET /api/tracks
|
||||
```
|
||||
|
||||
### Like/Favorite
|
||||
```
|
||||
POST /api/tracks/{id}/like
|
||||
GET /api/me/likes
|
||||
DELETE /api/tracks/{id}/like
|
||||
```
|
||||
|
||||
### Create Content (Admin)
|
||||
```
|
||||
POST /api/artists
|
||||
POST /api/albums
|
||||
POST /api/tracks
|
||||
```
|
||||
|
||||
### Manage Users (Admin)
|
||||
```
|
||||
GET /api/users
|
||||
POST /api/users/{id}
|
||||
DELETE /api/users/{id}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📖 Reading Order Recommendation
|
||||
|
||||
1. **This file** (2 min) - Get oriented
|
||||
2. **API_QUICK_REFERENCE.md** (5 min) - See all endpoints
|
||||
3. **API_EXAMPLES.md** (10 min) - See request/response examples
|
||||
4. **routes/api.php** (5 min) - Read actual route definitions
|
||||
5. **app/Http/Controllers/** (10 min) - Read controller implementations
|
||||
6. **app/Models/** (5 min) - Understand data models
|
||||
7. **API_DOCUMENTATION.md** (20 min) - Deep dive on everything
|
||||
|
||||
Total time: ~60 minutes for complete understanding
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Need More Info?
|
||||
|
||||
- **Routes:** See `/routes/api.php` - single file with all endpoints
|
||||
- **Controllers:** See `/app/Http/Controllers/` - one per resource
|
||||
- **Models:** See `/app/Models/` - Eloquent models with relationships
|
||||
- **Database:** See `/database/migrations/` - migration files
|
||||
- **Auth:** See `/config/sanctum.php` and `/config/auth.php`
|
||||
|
||||
---
|
||||
|
||||
## 📋 Endpoint Summary
|
||||
|
||||
| Category | Public | Authenticated | Admin-Only |
|
||||
|----------|--------|---------------|-----------|
|
||||
| Auth | 2 | 2 | 0 |
|
||||
| Browse | 0 | 10 | 0 |
|
||||
| Likes | 0 | 3 | 0 |
|
||||
| Labels | 0 | 1 | 3 |
|
||||
| Genres | 0 | 1 | 3 |
|
||||
| Artists | 0 | 1 | 3 |
|
||||
| Albums | 0 | 1 | 3 |
|
||||
| Tracks | 0 | 1 | 3 |
|
||||
| Users | 0 | 0 | 4 |
|
||||
| **TOTAL** | **2** | **19** | **19** |
|
||||
|
||||
**Total Endpoints: 40+**
|
||||
|
||||
---
|
||||
|
||||
## ✅ Checklist for Understanding the API
|
||||
|
||||
After reading the documentation, you should understand:
|
||||
|
||||
- [ ] What are the 2 public endpoints?
|
||||
- [ ] How to authenticate (register → login → token)?
|
||||
- [ ] How to use the token in requests?
|
||||
- [ ] The 3 endpoint categories (public, authenticated, admin)?
|
||||
- [ ] All 7 data models and their relationships?
|
||||
- [ ] The database schema and table structure?
|
||||
- [ ] How admin access control works?
|
||||
- [ ] Response format (success and error)?
|
||||
- [ ] HTTP status codes (200, 201, 204, 403, 404, 422)?
|
||||
- [ ] How to like a track and get favorites?
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Next Steps
|
||||
|
||||
1. **For Frontend Integration:** Read API_QUICK_REFERENCE.md + API_EXAMPLES.md
|
||||
2. **For Backend Development:** Read API_DOCUMENTATION.md thoroughly
|
||||
3. **For Testing:** Use test user credentials in API_EXAMPLES.md
|
||||
4. **For Production:** Address limitations in API_DOCUMENTATION.md §11
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** May 7, 2026
|
||||
|
||||
**Documentation Version:** 1.0
|
||||
|
||||
**API Version:** Laravel 13 + Sanctum 4
|
||||
|
||||
---
|
||||
|
||||
## Questions?
|
||||
|
||||
Refer to the appropriate documentation file:
|
||||
- Quick question? → API_QUICK_REFERENCE.md
|
||||
- How do I do X? → API_EXAMPLES.md
|
||||
- Why is it built this way? → API_DOCUMENTATION.md
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Album;
|
||||
use App\Models\Track;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AlbumController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(Album::with(['label', 'artist', 'genres', 'tracks.artists', 'tracks.genres'])->get());
|
||||
}
|
||||
|
||||
public function show(Album $album): JsonResponse
|
||||
{
|
||||
return response()->json($album->load(['label', 'artist', 'genres', 'tracks.artists', 'tracks.genres']));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'cover_path' => 'nullable|string|max:255',
|
||||
'release_date' => 'nullable|date',
|
||||
'duration_seconds' => 'nullable|integer',
|
||||
'type' => 'nullable|in:album,single,ep',
|
||||
'label_id' => 'nullable|exists:labels,id',
|
||||
'artist_id' => 'nullable|exists:artists,id',
|
||||
'genre_ids' => 'nullable|array',
|
||||
'genre_ids.*' => 'exists:genres,id',
|
||||
]);
|
||||
|
||||
$genreIds = $data['genre_ids'] ?? [];
|
||||
unset($data['genre_ids']);
|
||||
|
||||
$album = Album::create($data);
|
||||
|
||||
if (!empty($genreIds)) {
|
||||
$album->genres()->sync($genreIds);
|
||||
}
|
||||
|
||||
if ($request->has('tracks')) {
|
||||
foreach ($request->input('tracks') as $index => $trackData) {
|
||||
$album->tracks()->create([
|
||||
'title' => $trackData['title'],
|
||||
'file_path' => $trackData['file_path'] ?? '',
|
||||
'position' => $trackData['position'] ?? $index,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($album->load(['label', 'artist', 'genres', 'tracks.artists', 'tracks.genres']), 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Album $album): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'title' => 'sometimes|required|string|max:255',
|
||||
'cover_path' => 'nullable|string|max:255',
|
||||
'release_date' => 'nullable|date',
|
||||
'duration_seconds' => 'nullable|integer',
|
||||
'type' => 'nullable|in:album,single,ep',
|
||||
'label_id' => 'nullable|exists:labels,id',
|
||||
'artist_id' => 'nullable|exists:artists,id',
|
||||
'genre_ids' => 'nullable|array',
|
||||
'genre_ids.*' => 'exists:genres,id',
|
||||
]);
|
||||
|
||||
$genreIds = $data['genre_ids'] ?? null;
|
||||
unset($data['genre_ids']);
|
||||
|
||||
$album->update($data);
|
||||
|
||||
if ($genreIds !== null) {
|
||||
$album->genres()->sync($genreIds);
|
||||
}
|
||||
|
||||
return response()->json($album->load(['label', 'artist', 'genres', 'tracks.artists', 'tracks.genres']));
|
||||
}
|
||||
|
||||
public function destroy(Album $album): JsonResponse
|
||||
{
|
||||
$album->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Artist;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ArtistController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(Artist::with('label')->get());
|
||||
}
|
||||
|
||||
public function show(Artist $artist): JsonResponse
|
||||
{
|
||||
return response()->json($artist->load(['label', 'tracks.album', 'tracks.genres']));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'cover_path' => 'nullable|string|max:255',
|
||||
'release_date' => 'nullable|date',
|
||||
'label_id' => 'nullable|exists:labels,id',
|
||||
'duration' => 'nullable|integer',
|
||||
]);
|
||||
|
||||
$artist = Artist::create($data);
|
||||
|
||||
return response()->json($artist->load('label'), 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Artist $artist): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => 'sometimes|required|string|max:255',
|
||||
'cover_path' => 'nullable|string|max:255',
|
||||
'release_date' => 'nullable|date',
|
||||
'label_id' => 'nullable|exists:labels,id',
|
||||
'duration' => 'nullable|integer',
|
||||
]);
|
||||
|
||||
$artist->update($data);
|
||||
|
||||
return response()->json($artist->load('label'));
|
||||
}
|
||||
|
||||
public function destroy(Artist $artist): JsonResponse
|
||||
{
|
||||
$artist->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function register(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
]);
|
||||
|
||||
$userRole = Role::where('name', 'user')->firstOrFail();
|
||||
|
||||
$user = User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => $data['password'],
|
||||
'role_id' => $userRole->id,
|
||||
]);
|
||||
|
||||
$token = $user->createToken('api')->plainTextToken;
|
||||
|
||||
return response()->json([
|
||||
'token' => $token,
|
||||
'user' => $user->load('role'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function login(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|string',
|
||||
]);
|
||||
|
||||
$user = User::where('email', $data['email'])->first();
|
||||
|
||||
if (! $user || ! Hash::check($data['password'], $user->password)) {
|
||||
throw ValidationException::withMessages([
|
||||
'email' => ['The provided credentials are incorrect.'],
|
||||
]);
|
||||
}
|
||||
|
||||
$token = $user->createToken('api')->plainTextToken;
|
||||
|
||||
return response()->json([
|
||||
'token' => $token,
|
||||
'user' => $user->load('role'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout(Request $request): JsonResponse
|
||||
{
|
||||
$request->user()->currentAccessToken()->delete();
|
||||
|
||||
return response()->json(['message' => 'Logged out.']);
|
||||
}
|
||||
|
||||
public function me(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json($request->user()->load('role'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Genre;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GenreController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(Genre::all());
|
||||
}
|
||||
|
||||
public function show(Genre $genre): JsonResponse
|
||||
{
|
||||
return response()->json($genre);
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate(['name' => 'required|string|max:100']);
|
||||
$genre = Genre::create($data);
|
||||
|
||||
return response()->json($genre, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Genre $genre): JsonResponse
|
||||
{
|
||||
$data = $request->validate(['name' => 'sometimes|required|string|max:100']);
|
||||
$genre->update($data);
|
||||
|
||||
return response()->json($genre);
|
||||
}
|
||||
|
||||
public function destroy(Genre $genre): JsonResponse
|
||||
{
|
||||
$genre->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Label;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LabelController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(Label::all());
|
||||
}
|
||||
|
||||
public function show(Label $label): JsonResponse
|
||||
{
|
||||
return response()->json($label);
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate(['name' => 'required|string|max:100']);
|
||||
$label = Label::create($data);
|
||||
|
||||
return response()->json($label, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Label $label): JsonResponse
|
||||
{
|
||||
$data = $request->validate(['name' => 'sometimes|required|string|max:100']);
|
||||
$label->update($data);
|
||||
|
||||
return response()->json($label);
|
||||
}
|
||||
|
||||
public function destroy(Label $label): JsonResponse
|
||||
{
|
||||
$label->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Track;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LikeController extends Controller
|
||||
{
|
||||
public function like(Request $request, Track $track): JsonResponse
|
||||
{
|
||||
$request->user()->likes()->syncWithoutDetaching([$track->id]);
|
||||
|
||||
return response()->json(['message' => 'Track liked.']);
|
||||
}
|
||||
|
||||
public function unlike(Request $request, Track $track): JsonResponse
|
||||
{
|
||||
$request->user()->likes()->detach($track->id);
|
||||
|
||||
return response()->json(['message' => 'Track unliked.']);
|
||||
}
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$tracks = $request->user()->likes()->with(['album', 'artists', 'genres'])->get();
|
||||
|
||||
return response()->json($tracks);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Album;
|
||||
use App\Models\Track;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrackController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(Track::with(['album', 'artists', 'genres'])->orderBy('position')->get());
|
||||
}
|
||||
|
||||
public function show(Track $track): JsonResponse
|
||||
{
|
||||
return response()->json($track->load(['album.label', 'artists', 'genres']));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'file_path' => 'required|string|max:255',
|
||||
'duration_seconds' => 'nullable|integer',
|
||||
'album_id' => 'nullable|exists:albums,id',
|
||||
'position' => 'nullable|integer',
|
||||
'artist_ids' => 'nullable|array',
|
||||
'artist_ids.*' => 'exists:artists,id',
|
||||
'genre_ids' => 'nullable|array',
|
||||
'genre_ids.*' => 'exists:genres,id',
|
||||
]);
|
||||
|
||||
if (!isset($data['position']) && isset($data['album_id'])) {
|
||||
$data['position'] = Track::where('album_id', $data['album_id'])->max('position') + 1;
|
||||
}
|
||||
|
||||
$track = Track::create($data);
|
||||
|
||||
if (!empty($data['artist_ids'])) {
|
||||
$track->artists()->sync($data['artist_ids']);
|
||||
}
|
||||
|
||||
if (!empty($data['genre_ids'])) {
|
||||
$track->genres()->sync($data['genre_ids']);
|
||||
}
|
||||
|
||||
return response()->json($track->load(['album', 'artists', 'genres']), 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Track $track): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'title' => 'sometimes|required|string|max:255',
|
||||
'file_path' => 'sometimes|required|string|max:255',
|
||||
'duration_seconds' => 'nullable|integer',
|
||||
'album_id' => 'nullable|exists:albums,id',
|
||||
'position' => 'nullable|integer',
|
||||
'artist_ids' => 'nullable|array',
|
||||
'artist_ids.*' => 'exists:artists,id',
|
||||
'genre_ids' => 'nullable|array',
|
||||
'genre_ids.*' => 'exists:genres,id',
|
||||
]);
|
||||
|
||||
$track->update($data);
|
||||
|
||||
if (array_key_exists('artist_ids', $data)) {
|
||||
$track->artists()->sync($data['artist_ids'] ?? []);
|
||||
}
|
||||
|
||||
if (array_key_exists('genre_ids', $data)) {
|
||||
$track->genres()->sync($data['genre_ids'] ?? []);
|
||||
}
|
||||
|
||||
return response()->json($track->load(['album', 'artists', 'genres']));
|
||||
}
|
||||
|
||||
public function destroy(Track $track): JsonResponse
|
||||
{
|
||||
$track->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
public function reorder(Request $request, Album $album): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'positions' => 'required|array',
|
||||
'positions.*.id' => 'required|exists:tracks,id',
|
||||
'positions.*.position' => 'required|integer|min:0',
|
||||
]);
|
||||
|
||||
foreach ($data['positions'] as $item) {
|
||||
Track::where('id', $item['id'])
|
||||
->where('album_id', $album->id)
|
||||
->update(['position' => $item['position']]);
|
||||
}
|
||||
|
||||
return response()->json(
|
||||
$album->load(['tracks.artists', 'tracks.genres'])->tracks->sortBy('position')->values()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UploadController extends Controller
|
||||
{
|
||||
public function image(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'file' => 'required|image|max:10240',
|
||||
]);
|
||||
|
||||
$path = $request->file('file')->store('covers', 'public');
|
||||
|
||||
return response()->json(['path' => $path]);
|
||||
}
|
||||
|
||||
public function audio(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'file' => 'required|file|mimes:mp3,wav,flac,ogg,aac|max:51200',
|
||||
]);
|
||||
|
||||
$path = $request->file('file')->store('tracks', 'public');
|
||||
|
||||
return response()->json(['path' => $path]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(User::with('role')->get());
|
||||
}
|
||||
|
||||
public function show(User $user): JsonResponse
|
||||
{
|
||||
return response()->json($user->load('role'));
|
||||
}
|
||||
|
||||
public function update(Request $request, User $user): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => 'sometimes|required|string|max:255',
|
||||
'email' => 'sometimes|required|email|unique:users,email,' . $user->id,
|
||||
'password' => 'sometimes|required|string|min:8|confirmed',
|
||||
'role_id' => 'sometimes|required|exists:roles,id',
|
||||
]);
|
||||
|
||||
$user->update($data);
|
||||
|
||||
return response()->json($user->load('role'));
|
||||
}
|
||||
|
||||
public function destroy(User $user): JsonResponse
|
||||
{
|
||||
$user->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class Cors
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if ($request->isMethod('OPTIONS')) {
|
||||
$response = response('', 200);
|
||||
} else {
|
||||
$response = $next($request);
|
||||
}
|
||||
|
||||
$response->headers->set('Access-Control-Allow-Origin', '*');
|
||||
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE, OPTIONS');
|
||||
$response->headers->set('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With, Accept');
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class EnsureAdmin
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if ($request->user()?->role?->name !== 'admin') {
|
||||
return response()->json(['message' => 'Forbidden.'], 403);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Album extends Model
|
||||
{
|
||||
protected $fillable = ['title', 'cover_path', 'release_date', 'duration_seconds', 'type', 'label_id', 'artist_id'];
|
||||
|
||||
public function label(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Label::class);
|
||||
}
|
||||
|
||||
public function artist(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Artist::class);
|
||||
}
|
||||
|
||||
public function genres(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Genre::class, 'album_genre');
|
||||
}
|
||||
|
||||
public function tracks(): HasMany
|
||||
{
|
||||
return $this->hasMany(Track::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Artist extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'cover_path', 'release_date', 'label_id', 'duration'];
|
||||
|
||||
public function label(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Label::class);
|
||||
}
|
||||
|
||||
public function tracks(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Track::class, 'artist_track');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Genre extends Model
|
||||
{
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function tracks(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Track::class, 'track_genre');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Label extends Model
|
||||
{
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function artists(): HasMany
|
||||
{
|
||||
return $this->hasMany(Artist::class);
|
||||
}
|
||||
|
||||
public function albums(): HasMany
|
||||
{
|
||||
return $this->hasMany(Album::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Role extends Model
|
||||
{
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Track extends Model
|
||||
{
|
||||
protected $fillable = ['title', 'file_path', 'duration_seconds', 'album_id', 'position'];
|
||||
|
||||
public function album(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Album::class);
|
||||
}
|
||||
|
||||
public function artists(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Artist::class, 'artist_track');
|
||||
}
|
||||
|
||||
public function genres(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Genre::class, 'track_genre');
|
||||
}
|
||||
|
||||
public function likedBy(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'likes');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
#[Fillable(['name', 'email', 'password', 'role_id'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function role(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Role::class);
|
||||
}
|
||||
|
||||
public function likes(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Track::class, 'likes');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the command...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$status = $app->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Middleware\Cors;
|
||||
use App\Http\Middleware\EnsureAdmin;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->prepend(Cors::class);
|
||||
$middleware->alias([
|
||||
'admin' => EnsureAdmin::class,
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
})->create();
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Providers\AppServiceProvider;
|
||||
|
||||
return [
|
||||
AppServiceProvider::class,
|
||||
];
|
||||
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.3",
|
||||
"laravel/framework": "^13.0",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/tinker": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pail": "^1.2.5",
|
||||
"laravel/pint": "^1.27",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"phpunit/phpunit": "^12.5.12"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"setup": [
|
||||
"composer install",
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||
"@php artisan key:generate",
|
||||
"@php artisan migrate --force",
|
||||
"npm install --ignore-scripts",
|
||||
"npm run build"
|
||||
],
|
||||
"dev": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@php artisan test"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
],
|
||||
"pre-package-uninstall": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
||||
Generated
+8089
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', User::class),
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the number of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
|
||||
];
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_STORE', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "array", "database", "file", "memcached",
|
||||
| "redis", "dynamodb", "octane",
|
||||
| "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'stores' => [
|
||||
'database',
|
||||
'array',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Serializable Classes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the classes that can be unserialized from cache
|
||||
| storage. By default, no PHP classes will be unserialized from your
|
||||
| cache to prevent gadget chain attacks if your APP_KEY is leaked.
|
||||
|
|
||||
*/
|
||||
|
||||
'serializable_classes' => false,
|
||||
|
||||
];
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Pdo\Mysql;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for database operations. This is
|
||||
| the connection which will be utilized unless another connection
|
||||
| is explicitly specified when you execute a query / statement.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below are all of the database connections defined for your application.
|
||||
| An example configuration is provided for each database system which
|
||||
| is supported by Laravel. You're free to add / remove connections.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DB_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'busy_timeout' => null,
|
||||
'journal_mode' => null,
|
||||
'synchronous' => null,
|
||||
'transaction_mode' => 'DEFERRED',
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => env('DB_SSLMODE', 'prefer'),
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run on the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as Memcached. You may define your connection settings here.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'serve' => true,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', env('APP_NAME', 'Laravel')),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'handler_with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send all email
|
||||
| messages unless another mailer is explicitly specified when sending
|
||||
| the message. All additional mailers can be configured within the
|
||||
| "mailers" array. Examples of each type of mailer are provided.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'log'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||
| when delivering an email. You may specify which one you're using for
|
||||
| your mailers below. You may also add additional mailers if needed.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "resend", "log", "array",
|
||||
| "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'transport' => 'resend',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all emails sent by your application to be sent from
|
||||
| the same address. Here you may specify a name and address that is
|
||||
| used globally for all emails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue supports a variety of backends via a single, unified
|
||||
| API, giving you convenient access to each backend using identical
|
||||
| syntax for each. The default queue connection is defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection options for every queue backend
|
||||
| used by your application. An example configuration is provided for
|
||||
| each backend supported by Laravel. You're also free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
|
||||
| "deferred", "background", "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'deferred' => [
|
||||
'driver' => 'deferred',
|
||||
],
|
||||
|
||||
'background' => [
|
||||
'driver' => 'background',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'connections' => [
|
||||
'database',
|
||||
'deferred',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control how and where failed jobs are stored. Laravel ships with
|
||||
| support for storing failed jobs in a simple file or in a database.
|
||||
|
|
||||
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stateful Domains
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Requests from the following domains / hosts will receive stateful API
|
||||
| authentication cookies. Typically, these should include your local
|
||||
| and production domains which access your API via a frontend SPA.
|
||||
|
|
||||
*/
|
||||
|
||||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||
'%s%s',
|
||||
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||
Sanctum::currentApplicationUrlWithPort(),
|
||||
// Sanctum::currentRequestHost(),
|
||||
))),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array contains the authentication guards that will be checked when
|
||||
| Sanctum is trying to authenticate a request. If none of these guards
|
||||
| are able to authenticate the request, Sanctum will use the bearer
|
||||
| token that's present on an incoming request for authentication.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expiration Minutes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the number of minutes until an issued token will be
|
||||
| considered expired. This will override any values set in the token's
|
||||
| "expires_at" attribute, but first-party sessions are not affected.
|
||||
|
|
||||
*/
|
||||
|
||||
'expiration' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Token Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Sanctum can prefix new tokens in order to take advantage of numerous
|
||||
| security scanning initiatives maintained by open source platforms
|
||||
| that notify developers if they commit tokens into repositories.
|
||||
|
|
||||
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
||||
|
|
||||
*/
|
||||
|
||||
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When authenticating your first-party SPA with Sanctum you may need to
|
||||
| customize some of the middleware Sanctum uses while processing the
|
||||
| request. You may change the middleware listed below as required.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => [
|
||||
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'key' => env('POSTMARK_API_KEY'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_API_KEY'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "memcached",
|
||||
| "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain without subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Serialization
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the serialization strategy for session data, which
|
||||
| is JSON by default. Setting this to "php" allows the storage of PHP
|
||||
| objects in the session but can make an application vulnerable to
|
||||
| "gadget chain" serialization attacks if the APP_KEY is leaked.
|
||||
|
|
||||
| Supported: "json", "php"
|
||||
|
|
||||
*/
|
||||
|
||||
'serialization' => 'json',
|
||||
|
||||
];
|
||||
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('labels', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 100);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('labels');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('genres', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 100);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('genres');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('roles');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('password');
|
||||
$table->foreignId('role_id')->constrained('roles');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('artists', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 255);
|
||||
$table->string('cover_path', 255)->nullable();
|
||||
$table->dateTime('release_date')->nullable();
|
||||
$table->foreignId('label_id')->nullable()->constrained('labels');
|
||||
$table->integer('duration')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('artists');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('albums', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title', 255);
|
||||
$table->string('cover_path', 255)->nullable();
|
||||
$table->dateTime('release_date')->nullable();
|
||||
$table->integer('duration_seconds')->nullable();
|
||||
$table->enum('type', ['album', 'single', 'ep'])->default('album');
|
||||
$table->foreignId('label_id')->nullable()->constrained('labels');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('albums');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tracks', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('file_path', 255);
|
||||
$table->string('title', 255);
|
||||
$table->integer('duration_seconds')->nullable();
|
||||
$table->foreignId('album_id')->nullable()->constrained('albums');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tracks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('artist_track', function (Blueprint $table) {
|
||||
$table->foreignId('artist_id')->constrained('artists');
|
||||
$table->foreignId('track_id')->constrained('tracks');
|
||||
$table->primary(['artist_id', 'track_id']);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('artist_track');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('track_genre', function (Blueprint $table) {
|
||||
$table->foreignId('track_id')->constrained('tracks');
|
||||
$table->foreignId('genre_id')->constrained('genres');
|
||||
$table->primary(['track_id', 'genre_id']);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('track_genre');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('likes', function (Blueprint $table) {
|
||||
$table->foreignId('user_id')->constrained('users');
|
||||
$table->foreignId('track_id')->constrained('tracks');
|
||||
$table->primary(['user_id', 'track_id']);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('likes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->text('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tracks', function (Blueprint $table) {
|
||||
$table->integer('position')->default(0)->after('album_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tracks', function (Blueprint $table) {
|
||||
$table->dropColumn('position');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('albums', function (Blueprint $table) {
|
||||
$table->foreignId('artist_id')->nullable()->after('label_id')->constrained('artists');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('albums', function (Blueprint $table) {
|
||||
$table->dropForeign(['artist_id']);
|
||||
$table->dropColumn('artist_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('album_genre', function (Blueprint $table) {
|
||||
$table->foreignId('album_id')->constrained('albums')->cascadeOnDelete();
|
||||
$table->foreignId('genre_id')->constrained('genres')->cascadeOnDelete();
|
||||
$table->primary(['album_id', 'genre_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('album_genre');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$adminRole = Role::firstOrCreate(['name' => 'admin']);
|
||||
$userRole = Role::firstOrCreate(['name' => 'user']);
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@example.com',
|
||||
'role_id' => $adminRole->id,
|
||||
]);
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
'role_id' => $userRole->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"$schema": "https://www.schemastore.org/package.json",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"concurrently": "^9.0.1",
|
||||
"laravel-vite-plugin": "^3.0.0",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^8.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory>tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory>tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<source>
|
||||
<include>
|
||||
<directory>app</directory>
|
||||
</include>
|
||||
</source>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="BROADCAST_CONNECTION" value="null"/>
|
||||
<env name="CACHE_STORE" value="array"/>
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
<env name="DB_URL" value=""/>
|
||||
<env name="MAIL_MAILER" value="array"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="PULSE_ENABLED" value="false"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
<env name="NIGHTWATCH_ENABLED" value="false"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
@@ -0,0 +1,25 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews -Indexes
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
# Handle X-XSRF-Token Header
|
||||
RewriteCond %{HTTP:x-xsrf-token} .
|
||||
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
|
||||
|
||||
# Redirect Trailing Slashes If Not A Folder...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} (.+)/$
|
||||
RewriteRule ^ %1 [L,R=301]
|
||||
|
||||
# Send Requests To Front Controller...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Determine if the application is in maintenance mode...
|
||||
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
|
||||
require $maintenance;
|
||||
}
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the request...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->handleRequest(Request::capture());
|
||||
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow:
|
||||
@@ -0,0 +1,11 @@
|
||||
@import 'tailwindcss';
|
||||
|
||||
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
|
||||
@source '../../storage/framework/views/*.php';
|
||||
@source '../**/*.blade.php';
|
||||
@source '../**/*.js';
|
||||
|
||||
@theme {
|
||||
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
||||
'Segoe UI Symbol', 'Noto Color Emoji';
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
//
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\AlbumController;
|
||||
use App\Http\Controllers\ArtistController;
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\Http\Controllers\GenreController;
|
||||
use App\Http\Controllers\LabelController;
|
||||
use App\Http\Controllers\LikeController;
|
||||
use App\Http\Controllers\TrackController;
|
||||
use App\Http\Controllers\UploadController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::post('/register', [AuthController::class, 'register']);
|
||||
Route::post('/login', [AuthController::class, 'login']);
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
|
||||
Route::post('/logout', [AuthController::class, 'logout']);
|
||||
Route::get('/me', [AuthController::class, 'me']);
|
||||
|
||||
Route::get('/me/likes', [LikeController::class, 'index']);
|
||||
Route::post('/tracks/{track}/like', [LikeController::class, 'like']);
|
||||
Route::delete('/tracks/{track}/like', [LikeController::class, 'unlike']);
|
||||
|
||||
Route::get('/labels', [LabelController::class, 'index']);
|
||||
Route::get('/labels/{label}', [LabelController::class, 'show']);
|
||||
Route::get('/genres', [GenreController::class, 'index']);
|
||||
Route::get('/genres/{genre}', [GenreController::class, 'show']);
|
||||
Route::get('/artists', [ArtistController::class, 'index']);
|
||||
Route::get('/artists/{artist}', [ArtistController::class, 'show']);
|
||||
Route::get('/albums', [AlbumController::class, 'index']);
|
||||
Route::get('/albums/{album}', [AlbumController::class, 'show']);
|
||||
Route::get('/tracks', [TrackController::class, 'index']);
|
||||
Route::get('/tracks/{track}', [TrackController::class, 'show']);
|
||||
|
||||
Route::middleware('admin')->group(function () {
|
||||
|
||||
Route::post('/labels', [LabelController::class, 'store']);
|
||||
Route::put('/labels/{label}', [LabelController::class, 'update']);
|
||||
Route::delete('/labels/{label}', [LabelController::class, 'destroy']);
|
||||
|
||||
Route::post('/genres', [GenreController::class, 'store']);
|
||||
Route::put('/genres/{genre}', [GenreController::class, 'update']);
|
||||
Route::delete('/genres/{genre}', [GenreController::class, 'destroy']);
|
||||
|
||||
Route::post('/artists', [ArtistController::class, 'store']);
|
||||
Route::put('/artists/{artist}', [ArtistController::class, 'update']);
|
||||
Route::delete('/artists/{artist}', [ArtistController::class, 'destroy']);
|
||||
|
||||
Route::post('/albums', [AlbumController::class, 'store']);
|
||||
Route::put('/albums/{album}', [AlbumController::class, 'update']);
|
||||
Route::delete('/albums/{album}', [AlbumController::class, 'destroy']);
|
||||
|
||||
Route::post('/tracks', [TrackController::class, 'store']);
|
||||
Route::put('/tracks/{track}', [TrackController::class, 'update']);
|
||||
Route::delete('/tracks/{track}', [TrackController::class, 'destroy']);
|
||||
|
||||
Route::put('/albums/{album}/tracks/reorder', [TrackController::class, 'reorder']);
|
||||
|
||||
Route::post('/upload/image', [UploadController::class, 'image']);
|
||||
Route::post('/upload/audio', [UploadController::class, 'audio']);
|
||||
|
||||
Route::get('/users', [UserController::class, 'index']);
|
||||
Route::get('/users/{user}', [UserController::class, 'show']);
|
||||
Route::put('/users/{user}', [UserController::class, 'update']);
|
||||
Route::delete('/users/{user}', [UserController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
*
|
||||
!private/
|
||||
!public/
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,9 @@
|
||||
compiled.php
|
||||
config.php
|
||||
down
|
||||
events.scanned.php
|
||||
maintenance.php
|
||||
routes.php
|
||||
routes.scanned.php
|
||||
schedule-*
|
||||
services.json
|
||||
@@ -0,0 +1,3 @@
|
||||
*
|
||||
!data/
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
// use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*/
|
||||
public function test_the_application_returns_a_successful_response(): void
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*/
|
||||
public function test_that_true_is_true(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
laravel({
|
||||
input: ['resources/css/app.css', 'resources/js/app.js'],
|
||||
refresh: true,
|
||||
}),
|
||||
tailwindcss(),
|
||||
],
|
||||
server: {
|
||||
watch: {
|
||||
ignored: ['**/storage/framework/views/**'],
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user