mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 13:41:23 +00:00
Laravel 13 upgrade, updates and fixes
This commit is contained in:
11
.cursor/mcp.json
Normal file
11
.cursor/mcp.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"laravel-boost": {
|
||||||
|
"command": "php",
|
||||||
|
"args": [
|
||||||
|
"artisan",
|
||||||
|
"boost:mcp"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
106
.cursor/skills/medialibrary-development/SKILL.md
Normal file
106
.cursor/skills/medialibrary-development/SKILL.md
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
---
|
||||||
|
name: medialibrary-development
|
||||||
|
description: Build and work with spatie/laravel-medialibrary features including associating files with Eloquent models, defining media collections and conversions, generating responsive images, and retrieving media URLs and paths.
|
||||||
|
license: MIT
|
||||||
|
metadata:
|
||||||
|
author: Spatie
|
||||||
|
---
|
||||||
|
|
||||||
|
# Media Library Development
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Use spatie/laravel-medialibrary to associate files with Eloquent models. Supports image/video conversions, responsive images, multiple collections, and various storage disks.
|
||||||
|
|
||||||
|
## When to Activate
|
||||||
|
|
||||||
|
- Activate when working with file uploads, media attachments, or image processing in Laravel.
|
||||||
|
- Activate when code references `HasMedia`, `InteractsWithMedia`, the `Media` model, or media collections/conversions.
|
||||||
|
- Activate when the user wants to add, retrieve, convert, or manage files attached to Eloquent models.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
- In scope: media uploads, collections, conversions, responsive images, custom properties, file retrieval, path/URL generation.
|
||||||
|
- Out of scope: general file storage without Eloquent association, non-Laravel frameworks.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. Identify the task (model setup, adding media, defining conversions, retrieving files, etc.).
|
||||||
|
2. Read `references/medialibrary-guide.md` and focus on the relevant section.
|
||||||
|
3. Apply the patterns from the reference, keeping code minimal and Laravel-native.
|
||||||
|
|
||||||
|
## Core Concepts
|
||||||
|
|
||||||
|
### Model Setup
|
||||||
|
|
||||||
|
Every model that should have media must implement `HasMedia` and use the `InteractsWithMedia` trait:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||||
|
|
||||||
|
class BlogPost extends Model implements HasMedia
|
||||||
|
{
|
||||||
|
use InteractsWithMedia;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding Media
|
||||||
|
|
||||||
|
```php
|
||||||
|
$blogPost->addMedia($file)->toMediaCollection('images');
|
||||||
|
$blogPost->addMediaFromUrl($url)->toMediaCollection('images');
|
||||||
|
$blogPost->addMediaFromRequest('file')->toMediaCollection('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Defining Collections
|
||||||
|
|
||||||
|
```php
|
||||||
|
public function registerMediaCollections(): void
|
||||||
|
{
|
||||||
|
$this->addMediaCollection('avatar')->singleFile();
|
||||||
|
$this->addMediaCollection('downloads')->useDisk('s3');
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Defining Conversions
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||||
|
use Spatie\Image\Enums\Fit;
|
||||||
|
|
||||||
|
public function registerMediaConversions(?Media $media = null): void
|
||||||
|
{
|
||||||
|
$this->addMediaConversion('thumb')
|
||||||
|
->fit(Fit::Contain, 300, 300)
|
||||||
|
->nonQueued();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Retrieving Media
|
||||||
|
|
||||||
|
```php
|
||||||
|
$url = $model->getFirstMediaUrl('images');
|
||||||
|
$thumbUrl = $model->getFirstMediaUrl('images', 'thumb');
|
||||||
|
$allMedia = $model->getMedia('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Do and Don't
|
||||||
|
|
||||||
|
Do:
|
||||||
|
- Always implement the `HasMedia` interface alongside the `InteractsWithMedia` trait.
|
||||||
|
- Use `?Media $media = null` as the parameter for `registerMediaConversions()`.
|
||||||
|
- Call `->toMediaCollection()` to finalize adding media.
|
||||||
|
- Use `->nonQueued()` for conversions that should run synchronously.
|
||||||
|
- Use `->singleFile()` on collections that should only hold one file.
|
||||||
|
- Use `Spatie\Image\Enums\Fit` enum values for fit methods.
|
||||||
|
|
||||||
|
Don't:
|
||||||
|
- Don't forget to run `php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-migrations"` before migrating.
|
||||||
|
- Don't use `env()` for disk configuration; use `config()` or set it in `config/media-library.php`.
|
||||||
|
- Don't call `addMedia()` without calling `toMediaCollection()` — the media won't be saved.
|
||||||
|
- Don't reference conversion names that aren't registered in `registerMediaConversions()`.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- `references/medialibrary-guide.md`
|
||||||
@@ -0,0 +1,577 @@
|
|||||||
|
# Laravel Media Library Reference
|
||||||
|
|
||||||
|
Complete reference for `spatie/laravel-medialibrary`. Full documentation: https://spatie.be/docs/laravel-medialibrary
|
||||||
|
|
||||||
|
## Model Setup
|
||||||
|
|
||||||
|
Implement `HasMedia` and use `InteractsWithMedia`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||||
|
|
||||||
|
class BlogPost extends Model implements HasMedia
|
||||||
|
{
|
||||||
|
use InteractsWithMedia;
|
||||||
|
|
||||||
|
public function registerMediaCollections(): void
|
||||||
|
{
|
||||||
|
$this->addMediaCollection('images');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerMediaConversions(?Media $media = null): void
|
||||||
|
{
|
||||||
|
$this->addMediaConversion('thumb')
|
||||||
|
->fit(Fit::Contain, 300, 300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Adding Media
|
||||||
|
|
||||||
|
### From uploaded file
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMedia($request->file('image'))->toMediaCollection('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
### From request (shorthand)
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMediaFromRequest('image')->toMediaCollection('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
### From URL
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMediaFromUrl('https://example.com/image.jpg')->toMediaCollection('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
### From string content
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMediaFromString('raw content')->usingFileName('file.txt')->toMediaCollection('files');
|
||||||
|
```
|
||||||
|
|
||||||
|
### From base64
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMediaFromBase64($base64Data)->usingFileName('photo.jpg')->toMediaCollection('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
### From stream
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMediaFromStream($stream)->usingFileName('file.pdf')->toMediaCollection('files');
|
||||||
|
```
|
||||||
|
|
||||||
|
### From existing disk
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMediaFromDisk('path/to/file.jpg', 's3')->toMediaCollection('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multiple files from request
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMultipleMediaFromRequest(['images'])->each(function ($fileAdder) {
|
||||||
|
$fileAdder->toMediaCollection('images');
|
||||||
|
});
|
||||||
|
|
||||||
|
$model->addAllMediaFromRequest()->each(function ($fileAdder) {
|
||||||
|
$fileAdder->toMediaCollection('images');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Copy instead of move
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->copyMedia($pathToFile)->toMediaCollection('images');
|
||||||
|
// or
|
||||||
|
$model->addMedia($pathToFile)->preservingOriginal()->toMediaCollection('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
## FileAdder Options
|
||||||
|
|
||||||
|
All methods are chainable before calling `toMediaCollection()`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMedia($file)
|
||||||
|
->usingName('Custom Name') // display name
|
||||||
|
->usingFileName('custom-name.jpg') // filename on disk
|
||||||
|
->setOrder(3) // order within collection
|
||||||
|
->withCustomProperties(['alt' => 'A landscape photo'])
|
||||||
|
->withManipulations(['thumb' => ['filter' => 'greyscale']])
|
||||||
|
->withResponsiveImages() // generate responsive variants
|
||||||
|
->storingConversionsOnDisk('s3') // put conversions on different disk
|
||||||
|
->addCustomHeaders(['CacheControl' => 'max-age=31536000'])
|
||||||
|
->toMediaCollection('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Store on cloud disk
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->addMedia($file)->toMediaCollectionOnCloudDisk('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Media Collections
|
||||||
|
|
||||||
|
Define in `registerMediaCollections()`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
public function registerMediaCollections(): void
|
||||||
|
{
|
||||||
|
// Basic collection
|
||||||
|
$this->addMediaCollection('images');
|
||||||
|
|
||||||
|
// Single file (replacing previous on new upload)
|
||||||
|
$this->addMediaCollection('avatar')
|
||||||
|
->singleFile();
|
||||||
|
|
||||||
|
// Keep only latest N items
|
||||||
|
$this->addMediaCollection('recent_photos')
|
||||||
|
->onlyKeepLatest(5);
|
||||||
|
|
||||||
|
// Specific disk
|
||||||
|
$this->addMediaCollection('downloads')
|
||||||
|
->useDisk('s3');
|
||||||
|
|
||||||
|
// With conversions disk
|
||||||
|
$this->addMediaCollection('photos')
|
||||||
|
->useDisk('s3')
|
||||||
|
->storeConversionsOnDisk('s3-thumbnails');
|
||||||
|
|
||||||
|
// MIME type restriction
|
||||||
|
$this->addMediaCollection('documents')
|
||||||
|
->acceptsMimeTypes(['application/pdf', 'application/zip']);
|
||||||
|
|
||||||
|
// Custom validation
|
||||||
|
$this->addMediaCollection('images')
|
||||||
|
->acceptsFile(function ($file) {
|
||||||
|
return $file->mimeType === 'image/jpeg';
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fallback URL/path when collection is empty
|
||||||
|
$this->addMediaCollection('avatar')
|
||||||
|
->singleFile()
|
||||||
|
->useFallbackUrl('/images/default-avatar.jpg')
|
||||||
|
->useFallbackPath(public_path('/images/default-avatar.jpg'));
|
||||||
|
|
||||||
|
// Enable responsive images for entire collection
|
||||||
|
$this->addMediaCollection('hero_images')
|
||||||
|
->withResponsiveImages();
|
||||||
|
|
||||||
|
// Collection-specific conversions
|
||||||
|
$this->addMediaCollection('photos')
|
||||||
|
->registerMediaConversions(function () {
|
||||||
|
$this->addMediaConversion('card')
|
||||||
|
->fit(Fit::Crop, 400, 400);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Media Conversions
|
||||||
|
|
||||||
|
Define in `registerMediaConversions()`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||||
|
use Spatie\Image\Enums\Fit;
|
||||||
|
|
||||||
|
public function registerMediaConversions(?Media $media = null): void
|
||||||
|
{
|
||||||
|
$this->addMediaConversion('thumb')
|
||||||
|
->fit(Fit::Contain, 300, 300)
|
||||||
|
->nonQueued();
|
||||||
|
|
||||||
|
$this->addMediaConversion('preview')
|
||||||
|
->fit(Fit::Crop, 500, 500)
|
||||||
|
->withResponsiveImages()
|
||||||
|
->queued();
|
||||||
|
|
||||||
|
$this->addMediaConversion('banner')
|
||||||
|
->fit(Fit::Max, 1200, 630)
|
||||||
|
->performOnCollections('images', 'headers')
|
||||||
|
->nonQueued()
|
||||||
|
->sharpen(10);
|
||||||
|
|
||||||
|
// Conditional conversion based on media properties
|
||||||
|
if ($media?->mime_type === 'image/png') {
|
||||||
|
$this->addMediaConversion('png-thumb')
|
||||||
|
->fit(Fit::Contain, 150, 150);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep original format instead of converting to jpg
|
||||||
|
$this->addMediaConversion('web')
|
||||||
|
->fit(Fit::Max, 800, 800)
|
||||||
|
->keepOriginalImageFormat();
|
||||||
|
|
||||||
|
// PDF page rendering
|
||||||
|
$this->addMediaConversion('pdf-preview')
|
||||||
|
->pdfPageNumber(1)
|
||||||
|
->fit(Fit::Contain, 400, 400);
|
||||||
|
|
||||||
|
// Video frame extraction
|
||||||
|
$this->addMediaConversion('video-thumb')
|
||||||
|
->extractVideoFrameAtSecond(5)
|
||||||
|
->fit(Fit::Crop, 300, 300);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Image Manipulation Methods (via spatie/image)
|
||||||
|
|
||||||
|
Resizing and fitting:
|
||||||
|
- `width(int)`, `height(int)` — constrain dimensions
|
||||||
|
- `fit(Fit, int, int)` — fit within bounds using `Fit::Contain`, `Fit::Max`, `Fit::Fill`, `Fit::Stretch`, `Fit::Crop`
|
||||||
|
- `crop(int, int)` — crop to exact dimensions
|
||||||
|
|
||||||
|
Effects:
|
||||||
|
- `sharpen(int)`, `blur(int)`, `pixelate(int)`
|
||||||
|
- `greyscale()`, `sepia()`
|
||||||
|
- `brightness(int)`, `contrast(int)`, `colorize(int, int, int)`
|
||||||
|
|
||||||
|
Orientation:
|
||||||
|
- `orientation(int)`, `flip(string)`, `rotate(int)`
|
||||||
|
|
||||||
|
Format:
|
||||||
|
- `format(string)` — `'jpg'`, `'png'`, `'webp'`, `'avif'`
|
||||||
|
- `quality(int)` — 1-100
|
||||||
|
|
||||||
|
Other:
|
||||||
|
- `border(int, string, string)`, `watermark(string)`
|
||||||
|
- `optimize()`, `nonOptimized()`
|
||||||
|
|
||||||
|
### Conversion Configuration
|
||||||
|
|
||||||
|
- `performOnCollections('col1', 'col2')` — limit to specific collections
|
||||||
|
- `queued()` / `nonQueued()` — run async or sync
|
||||||
|
- `withResponsiveImages()` — also generate responsive variants for this conversion
|
||||||
|
- `keepOriginalImageFormat()` — preserve png/webp/gif instead of converting to jpg
|
||||||
|
- `pdfPageNumber(int)` — which PDF page to render
|
||||||
|
- `extractVideoFrameAtSecond(int)` — video thumbnail timing
|
||||||
|
|
||||||
|
## Retrieving Media
|
||||||
|
|
||||||
|
### Getting media items
|
||||||
|
|
||||||
|
```php
|
||||||
|
$media = $model->getMedia('images'); // all in collection
|
||||||
|
$first = $model->getFirstMedia('images'); // first item
|
||||||
|
$last = $model->getLastMedia('images'); // last item
|
||||||
|
$has = $model->hasMedia('images'); // boolean check
|
||||||
|
```
|
||||||
|
|
||||||
|
### Getting URLs
|
||||||
|
|
||||||
|
```php
|
||||||
|
$url = $model->getFirstMediaUrl('images'); // original URL
|
||||||
|
$thumbUrl = $model->getFirstMediaUrl('images', 'thumb'); // conversion URL
|
||||||
|
$lastUrl = $model->getLastMediaUrl('images', 'thumb');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Getting paths
|
||||||
|
|
||||||
|
```php
|
||||||
|
$path = $model->getFirstMediaPath('images');
|
||||||
|
$thumbPath = $model->getFirstMediaPath('images', 'thumb');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Temporary URLs (S3)
|
||||||
|
|
||||||
|
```php
|
||||||
|
$tempUrl = $model->getFirstTemporaryUrl(
|
||||||
|
now()->addMinutes(30),
|
||||||
|
'images',
|
||||||
|
'thumb'
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Fallback URLs
|
||||||
|
|
||||||
|
```php
|
||||||
|
$url = $model->getFallbackMediaUrl('avatar');
|
||||||
|
```
|
||||||
|
|
||||||
|
### From the Media model
|
||||||
|
|
||||||
|
```php
|
||||||
|
$media = $model->getFirstMedia('images');
|
||||||
|
|
||||||
|
$media->getUrl(); // original URL
|
||||||
|
$media->getUrl('thumb'); // conversion URL
|
||||||
|
$media->getPath(); // disk path
|
||||||
|
$media->getFullUrl(); // full URL with domain
|
||||||
|
$media->getTemporaryUrl(now()->addMinutes(30));
|
||||||
|
$media->hasGeneratedConversion('thumb'); // check if conversion exists
|
||||||
|
```
|
||||||
|
|
||||||
|
### Filtering media
|
||||||
|
|
||||||
|
```php
|
||||||
|
$media = $model->getMedia('images', function (Media $media) {
|
||||||
|
return $media->getCustomProperty('featured') === true;
|
||||||
|
});
|
||||||
|
|
||||||
|
$media = $model->getMedia('images', ['mime_type' => 'image/jpeg']);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Custom Properties
|
||||||
|
|
||||||
|
Store arbitrary metadata on media items:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// When adding
|
||||||
|
$model->addMedia($file)
|
||||||
|
->withCustomProperties([
|
||||||
|
'alt' => 'Descriptive text',
|
||||||
|
'credits' => 'Photographer Name',
|
||||||
|
])
|
||||||
|
->toMediaCollection('images');
|
||||||
|
|
||||||
|
// Get/set on existing media
|
||||||
|
$media->setCustomProperty('alt', 'Updated text');
|
||||||
|
$media->save();
|
||||||
|
|
||||||
|
$alt = $media->getCustomProperty('alt');
|
||||||
|
$has = $media->hasCustomProperty('alt');
|
||||||
|
$media->forgetCustomProperty('alt');
|
||||||
|
$media->save();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Responsive Images
|
||||||
|
|
||||||
|
Generate multiple sizes for optimal loading:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// On the FileAdder
|
||||||
|
$model->addMedia($file)
|
||||||
|
->withResponsiveImages()
|
||||||
|
->toMediaCollection('images');
|
||||||
|
|
||||||
|
// On a conversion
|
||||||
|
$this->addMediaConversion('hero')
|
||||||
|
->fit(Fit::Max, 1200, 800)
|
||||||
|
->withResponsiveImages();
|
||||||
|
|
||||||
|
// On a collection
|
||||||
|
$this->addMediaCollection('photos')
|
||||||
|
->withResponsiveImages();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using in Blade
|
||||||
|
|
||||||
|
```blade
|
||||||
|
{{-- Renders img tag with srcset --}}
|
||||||
|
{{ $media->toHtml() }}
|
||||||
|
|
||||||
|
{{-- With attributes --}}
|
||||||
|
{{ $media->img()->attributes(['class' => 'w-full', 'alt' => 'Photo']) }}
|
||||||
|
|
||||||
|
{{-- Get srcset string --}}
|
||||||
|
<img src="{{ $media->getUrl() }}" srcset="{{ $media->getSrcset() }}" />
|
||||||
|
|
||||||
|
{{-- Responsive conversion --}}
|
||||||
|
<img src="{{ $media->getUrl('hero') }}" srcset="{{ $media->getSrcset('hero') }}" />
|
||||||
|
```
|
||||||
|
|
||||||
|
### Placeholder SVG
|
||||||
|
|
||||||
|
```php
|
||||||
|
$svg = $media->responsiveImages()->getPlaceholderSvg(); // tiny blurred base64 placeholder
|
||||||
|
```
|
||||||
|
|
||||||
|
## Managing Media
|
||||||
|
|
||||||
|
### Clear a collection
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->clearMediaCollection('images');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Clear except specific items
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->clearMediaCollectionExcept('images', $mediaToKeep);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Delete specific media
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->deleteMedia($mediaId);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Delete all media
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->deleteAllMedia();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Delete model but keep media files
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->deletePreservingMedia();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Reorder media
|
||||||
|
|
||||||
|
```php
|
||||||
|
Media::setNewOrder([3, 1, 2]); // media IDs in desired order
|
||||||
|
```
|
||||||
|
|
||||||
|
### Move/copy media between models
|
||||||
|
|
||||||
|
```php
|
||||||
|
$media->move($otherModel, 'images');
|
||||||
|
$media->copy($otherModel, 'images');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Spatie\MediaLibrary\MediaCollections\Events\MediaHasBeenAddedEvent;
|
||||||
|
use Spatie\MediaLibrary\Conversions\Events\ConversionWillStartEvent;
|
||||||
|
use Spatie\MediaLibrary\Conversions\Events\ConversionHasBeenCompletedEvent;
|
||||||
|
use Spatie\MediaLibrary\MediaCollections\Events\CollectionHasBeenClearedEvent;
|
||||||
|
```
|
||||||
|
|
||||||
|
Listen to these events to hook into the media lifecycle:
|
||||||
|
```php
|
||||||
|
Event::listen(MediaHasBeenAddedEvent::class, function ($event) {
|
||||||
|
$event->media; // the added Media model
|
||||||
|
});
|
||||||
|
|
||||||
|
Event::listen(ConversionHasBeenCompletedEvent::class, function ($event) {
|
||||||
|
$event->media;
|
||||||
|
$event->conversion;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Key `config/media-library.php` options:
|
||||||
|
|
||||||
|
```php
|
||||||
|
return [
|
||||||
|
'disk_name' => 'public', // default disk
|
||||||
|
'max_file_size' => 1024 * 1024 * 10, // 10MB
|
||||||
|
'queue_connection_name' => '', // queue connection
|
||||||
|
'queue_name' => '', // queue name
|
||||||
|
'queue_conversions_by_default' => true, // queue conversions
|
||||||
|
'media_model' => Spatie\MediaLibrary\MediaCollections\Models\Media::class,
|
||||||
|
'file_namer' => Spatie\MediaLibrary\Support\FileNamer\DefaultFileNamer::class,
|
||||||
|
'path_generator' => Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator::class,
|
||||||
|
'url_generator' => Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator::class,
|
||||||
|
'image_driver' => 'gd', // 'gd', 'imagick', or 'vips'
|
||||||
|
'image_optimizers' => [/* optimizer config */],
|
||||||
|
'version_urls' => true, // cache busting
|
||||||
|
'default_loading_attribute_value' => null, // 'lazy' for lazy loading
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom Path Generator
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;
|
||||||
|
|
||||||
|
class CustomPathGenerator implements PathGenerator
|
||||||
|
{
|
||||||
|
public function getPath(Media $media): string
|
||||||
|
{
|
||||||
|
return md5($media->id) . '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPathForConversions(Media $media): string
|
||||||
|
{
|
||||||
|
return $this->getPath($media) . 'conversions/';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPathForResponsiveImages(Media $media): string
|
||||||
|
{
|
||||||
|
return $this->getPath($media) . 'responsive/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom File Namer
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Spatie\MediaLibrary\Support\FileNamer\FileNamer;
|
||||||
|
|
||||||
|
class CustomFileNamer extends FileNamer
|
||||||
|
{
|
||||||
|
public function originalFileName(string $fileName): string
|
||||||
|
{
|
||||||
|
return Str::slug(pathinfo($fileName, PATHINFO_FILENAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function conversionFileName(string $fileName, Conversion $conversion): string
|
||||||
|
{
|
||||||
|
return $this->originalFileName($fileName) . '-' . $conversion->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function responsiveFileName(string $fileName): string
|
||||||
|
{
|
||||||
|
return pathinfo($fileName, PATHINFO_FILENAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom Media Model
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Spatie\MediaLibrary\MediaCollections\Models\Media as BaseMedia;
|
||||||
|
|
||||||
|
class Media extends BaseMedia
|
||||||
|
{
|
||||||
|
// Add custom methods, scopes, or override behavior
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Register in config: `'media_model' => App\Models\Media::class`
|
||||||
|
|
||||||
|
## Downloading Media
|
||||||
|
|
||||||
|
### Single file
|
||||||
|
|
||||||
|
```php
|
||||||
|
return $media->toResponse($request); // download
|
||||||
|
return $media->toInlineResponse($request); // display inline
|
||||||
|
return $media->stream(); // stream
|
||||||
|
```
|
||||||
|
|
||||||
|
### ZIP download of collection
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Spatie\MediaLibrary\Support\MediaStream;
|
||||||
|
|
||||||
|
return MediaStream::create('photos.zip')
|
||||||
|
->addMedia($model->getMedia('images'));
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using with API Resources
|
||||||
|
|
||||||
|
```php
|
||||||
|
class PostResource extends JsonResource
|
||||||
|
{
|
||||||
|
public function toArray($request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'title' => $this->title,
|
||||||
|
'image' => $this->getFirstMediaUrl('images'),
|
||||||
|
'thumb' => $this->getFirstMediaUrl('images', 'thumb'),
|
||||||
|
'media' => $this->getMedia('images')->map(function ($media) {
|
||||||
|
return [
|
||||||
|
'id' => $media->id,
|
||||||
|
'url' => $media->getUrl(),
|
||||||
|
'thumb' => $media->getUrl('thumb'),
|
||||||
|
'name' => $media->name,
|
||||||
|
'size' => $media->size,
|
||||||
|
'type' => $media->mime_type,
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
157
.cursor/skills/pest-testing/SKILL.md
Normal file
157
.cursor/skills/pest-testing/SKILL.md
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
---
|
||||||
|
name: pest-testing
|
||||||
|
description: "Use this skill for Pest PHP testing in Laravel projects only. Trigger whenever any test is being written, edited, fixed, or refactored — including fixing tests that broke after a code change, adding assertions, converting PHPUnit to Pest, adding datasets, and TDD workflows. Always activate when the user asks how to write something in Pest, mentions test files or directories (tests/Feature, tests/Unit, tests/Browser), or needs browser testing, smoke testing multiple pages for JS errors, or architecture tests. Covers: it()/expect() syntax, datasets, mocking, browser testing (visit/click/fill), smoke testing, arch(), Livewire component tests, RefreshDatabase, and all Pest 4 features. Do not use for factories, seeders, migrations, controllers, models, or non-test PHP code."
|
||||||
|
license: MIT
|
||||||
|
metadata:
|
||||||
|
author: laravel
|
||||||
|
---
|
||||||
|
|
||||||
|
# Pest Testing 4
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Use `search-docs` for detailed Pest 4 patterns and documentation.
|
||||||
|
|
||||||
|
## Basic Usage
|
||||||
|
|
||||||
|
### Creating Tests
|
||||||
|
|
||||||
|
All tests must be written using Pest. Use `php artisan make:test --pest {name}`.
|
||||||
|
|
||||||
|
### Test Organization
|
||||||
|
|
||||||
|
- Unit/Feature tests: `tests/Feature` and `tests/Unit` directories.
|
||||||
|
- Browser tests: `tests/Browser/` directory.
|
||||||
|
- Do NOT remove tests without approval - these are core application code.
|
||||||
|
|
||||||
|
### Basic Test Structure
|
||||||
|
|
||||||
|
<!-- Basic Pest Test Example -->
|
||||||
|
```php
|
||||||
|
it('is true', function () {
|
||||||
|
expect(true)->toBeTrue();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
|
||||||
|
- Run minimal tests with filter before finalizing: `php artisan test --compact --filter=testName`.
|
||||||
|
- Run all tests: `php artisan test --compact`.
|
||||||
|
- Run file: `php artisan test --compact tests/Feature/ExampleTest.php`.
|
||||||
|
|
||||||
|
## Assertions
|
||||||
|
|
||||||
|
Use specific assertions (`assertSuccessful()`, `assertNotFound()`) instead of `assertStatus()`:
|
||||||
|
|
||||||
|
<!-- Pest Response Assertion -->
|
||||||
|
```php
|
||||||
|
it('returns all', function () {
|
||||||
|
$this->postJson('/api/docs', [])->assertSuccessful();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
| Use | Instead of |
|
||||||
|
|-----|------------|
|
||||||
|
| `assertSuccessful()` | `assertStatus(200)` |
|
||||||
|
| `assertNotFound()` | `assertStatus(404)` |
|
||||||
|
| `assertForbidden()` | `assertStatus(403)` |
|
||||||
|
|
||||||
|
## Mocking
|
||||||
|
|
||||||
|
Import mock function before use: `use function Pest\Laravel\mock;`
|
||||||
|
|
||||||
|
## Datasets
|
||||||
|
|
||||||
|
Use datasets for repetitive tests (validation rules, etc.):
|
||||||
|
|
||||||
|
<!-- Pest Dataset Example -->
|
||||||
|
```php
|
||||||
|
it('has emails', function (string $email) {
|
||||||
|
expect($email)->not->toBeEmpty();
|
||||||
|
})->with([
|
||||||
|
'james' => 'james@laravel.com',
|
||||||
|
'taylor' => 'taylor@laravel.com',
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Pest 4 Features
|
||||||
|
|
||||||
|
| Feature | Purpose |
|
||||||
|
|---------|---------|
|
||||||
|
| Browser Testing | Full integration tests in real browsers |
|
||||||
|
| Smoke Testing | Validate multiple pages quickly |
|
||||||
|
| Visual Regression | Compare screenshots for visual changes |
|
||||||
|
| Test Sharding | Parallel CI runs |
|
||||||
|
| Architecture Testing | Enforce code conventions |
|
||||||
|
|
||||||
|
### Browser Test Example
|
||||||
|
|
||||||
|
Browser tests run in real browsers for full integration testing:
|
||||||
|
|
||||||
|
- Browser tests live in `tests/Browser/`.
|
||||||
|
- Use Laravel features like `Event::fake()`, `assertAuthenticated()`, and model factories.
|
||||||
|
- Use `RefreshDatabase` for clean state per test.
|
||||||
|
- Interact with page: click, type, scroll, select, submit, drag-and-drop, touch gestures.
|
||||||
|
- Test on multiple browsers (Chrome, Firefox, Safari) if requested.
|
||||||
|
- Test on different devices/viewports (iPhone 14 Pro, tablets) if requested.
|
||||||
|
- Switch color schemes (light/dark mode) when appropriate.
|
||||||
|
- Take screenshots or pause tests for debugging.
|
||||||
|
|
||||||
|
<!-- Pest Browser Test Example -->
|
||||||
|
```php
|
||||||
|
it('may reset the password', function () {
|
||||||
|
Notification::fake();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
|
||||||
|
$page = visit('/sign-in');
|
||||||
|
|
||||||
|
$page->assertSee('Sign In')
|
||||||
|
->assertNoJavaScriptErrors()
|
||||||
|
->click('Forgot Password?')
|
||||||
|
->fill('email', 'nuno@laravel.com')
|
||||||
|
->click('Send Reset Link')
|
||||||
|
->assertSee('We have emailed your password reset link!');
|
||||||
|
|
||||||
|
Notification::assertSent(ResetPassword::class);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Smoke Testing
|
||||||
|
|
||||||
|
Quickly validate multiple pages have no JavaScript errors:
|
||||||
|
|
||||||
|
<!-- Pest Smoke Testing Example -->
|
||||||
|
```php
|
||||||
|
$pages = visit(['/', '/about', '/contact']);
|
||||||
|
|
||||||
|
$pages->assertNoJavaScriptErrors()->assertNoConsoleLogs();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Visual Regression Testing
|
||||||
|
|
||||||
|
Capture and compare screenshots to detect visual changes.
|
||||||
|
|
||||||
|
### Test Sharding
|
||||||
|
|
||||||
|
Split tests across parallel processes for faster CI runs.
|
||||||
|
|
||||||
|
### Architecture Testing
|
||||||
|
|
||||||
|
Pest 4 includes architecture testing (from Pest 3):
|
||||||
|
|
||||||
|
<!-- Architecture Test Example -->
|
||||||
|
```php
|
||||||
|
arch('controllers')
|
||||||
|
->expect('App\Http\Controllers')
|
||||||
|
->toExtendNothing()
|
||||||
|
->toHaveSuffix('Controller');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Pitfalls
|
||||||
|
|
||||||
|
- Not importing `use function Pest\Laravel\mock;` before using mock
|
||||||
|
- Using `assertStatus(200)` instead of `assertSuccessful()`
|
||||||
|
- Forgetting datasets for repetitive validation tests
|
||||||
|
- Deleting tests without approval
|
||||||
|
- Forgetting `assertNoJavaScriptErrors()` in browser tests
|
||||||
91
.cursor/skills/tailwindcss-development/SKILL.md
Normal file
91
.cursor/skills/tailwindcss-development/SKILL.md
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
---
|
||||||
|
name: tailwindcss-development
|
||||||
|
description: "Always invoke when the user's message includes 'tailwind' in any form. Also invoke for: building responsive grid layouts (multi-column card grids, product grids), flex/grid page structures (dashboards with sidebars, fixed topbars, mobile-toggle navs), styling UI components (cards, tables, navbars, pricing sections, forms, inputs, badges), adding dark mode variants, fixing spacing or typography, and Tailwind v3/v4 work. The core use case: writing or fixing Tailwind utility classes in HTML templates (Blade, JSX, Vue). Skip for backend PHP logic, database queries, API routes, JavaScript with no HTML/CSS component, CSS file audits, build tool configuration, and vanilla CSS."
|
||||||
|
license: MIT
|
||||||
|
metadata:
|
||||||
|
author: laravel
|
||||||
|
---
|
||||||
|
|
||||||
|
# Tailwind CSS Development
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Use `search-docs` for detailed Tailwind CSS v3 patterns and documentation.
|
||||||
|
|
||||||
|
## Basic Usage
|
||||||
|
|
||||||
|
- Use Tailwind CSS classes to style HTML. Check and follow existing Tailwind conventions in the project before introducing new patterns.
|
||||||
|
- Offer to extract repeated patterns into components that match the project's conventions (e.g., Blade, JSX, Vue).
|
||||||
|
- Consider class placement, order, priority, and defaults. Remove redundant classes, add classes to parent or child elements carefully to reduce repetition, and group elements logically.
|
||||||
|
|
||||||
|
## Tailwind CSS v3 Specifics
|
||||||
|
|
||||||
|
- Always use Tailwind CSS v3 and verify you're using only classes it supports.
|
||||||
|
- Configuration is done in the `tailwind.config.js` file.
|
||||||
|
- Import using `@tailwind` directives:
|
||||||
|
|
||||||
|
<!-- v3 Import Syntax -->
|
||||||
|
```css
|
||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Spacing
|
||||||
|
|
||||||
|
When listing items, use gap utilities for spacing; don't use margins.
|
||||||
|
|
||||||
|
<!-- Gap Utilities -->
|
||||||
|
```html
|
||||||
|
<div class="flex gap-8">
|
||||||
|
<div>Item 1</div>
|
||||||
|
<div>Item 2</div>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dark Mode
|
||||||
|
|
||||||
|
If existing pages and components support dark mode, new pages and components must support it the same way, typically using the `dark:` variant:
|
||||||
|
|
||||||
|
<!-- Dark Mode -->
|
||||||
|
```html
|
||||||
|
<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-white">
|
||||||
|
Content adapts to color scheme
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Patterns
|
||||||
|
|
||||||
|
### Flexbox Layout
|
||||||
|
|
||||||
|
<!-- Flexbox Layout -->
|
||||||
|
```html
|
||||||
|
<div class="flex items-center justify-between gap-4">
|
||||||
|
<div>Left content</div>
|
||||||
|
<div>Right content</div>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grid Layout
|
||||||
|
|
||||||
|
<!-- Grid Layout -->
|
||||||
|
```html
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
|
<div>Card 1</div>
|
||||||
|
<div>Card 2</div>
|
||||||
|
<div>Card 3</div>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
1. Check browser for visual rendering
|
||||||
|
2. Test responsive breakpoints
|
||||||
|
3. Verify dark mode if project uses it
|
||||||
|
|
||||||
|
## Common Pitfalls
|
||||||
|
|
||||||
|
- Using margins for spacing between siblings instead of gap utilities
|
||||||
|
- Forgetting to add dark mode variants when the project uses dark mode
|
||||||
|
- Not checking existing project conventions before adding new utilities
|
||||||
|
- Overusing inline styles when Tailwind classes would suffice
|
||||||
234
AGENTS.md
Normal file
234
AGENTS.md
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
<laravel-boost-guidelines>
|
||||||
|
=== foundation rules ===
|
||||||
|
|
||||||
|
# Laravel Boost Guidelines
|
||||||
|
|
||||||
|
The Laravel Boost guidelines are specifically curated by Laravel maintainers for this application. These guidelines should be followed closely to ensure the best experience when building Laravel applications.
|
||||||
|
|
||||||
|
## Foundational Context
|
||||||
|
|
||||||
|
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
|
||||||
|
|
||||||
|
- php - 8.4
|
||||||
|
- laravel/framework (LARAVEL) - v13
|
||||||
|
- laravel/prompts (PROMPTS) - v0
|
||||||
|
- laravel/sanctum (SANCTUM) - v4
|
||||||
|
- phpunit/phpunit (PHPUNIT) - v12
|
||||||
|
- laravel/boost (BOOST) - v2
|
||||||
|
- laravel/mcp (MCP) - v0
|
||||||
|
- laravel/pint (PINT) - v1
|
||||||
|
- laravel/sail (SAIL) - v1
|
||||||
|
- pestphp/pest (PEST) - v4
|
||||||
|
- vue (VUE) - v3
|
||||||
|
- eslint (ESLINT) - v9
|
||||||
|
- prettier (PRETTIER) - v3
|
||||||
|
- tailwindcss (TAILWINDCSS) - v3
|
||||||
|
|
||||||
|
## Skills Activation
|
||||||
|
|
||||||
|
This project has domain-specific skills available. You MUST activate the relevant skill whenever you work in that domain—don't wait until you're stuck.
|
||||||
|
|
||||||
|
- `pest-testing` — Use this skill for Pest PHP testing in Laravel projects only. Trigger whenever any test is being written, edited, fixed, or refactored — including fixing tests that broke after a code change, adding assertions, converting PHPUnit to Pest, adding datasets, and TDD workflows. Always activate when the user asks how to write something in Pest, mentions test files or directories (tests/Feature, tests/Unit, tests/Browser), or needs browser testing, smoke testing multiple pages for JS errors, or architecture tests. Covers: it()/expect() syntax, datasets, mocking, browser testing (visit/click/fill), smoke testing, arch(), Livewire component tests, RefreshDatabase, and all Pest 4 features. Do not use for factories, seeders, migrations, controllers, models, or non-test PHP code.
|
||||||
|
- `tailwindcss-development` — Always invoke when the user's message includes 'tailwind' in any form. Also invoke for: building responsive grid layouts (multi-column card grids, product grids), flex/grid page structures (dashboards with sidebars, fixed topbars, mobile-toggle navs), styling UI components (cards, tables, navbars, pricing sections, forms, inputs, badges), adding dark mode variants, fixing spacing or typography, and Tailwind v3/v4 work. The core use case: writing or fixing Tailwind utility classes in HTML templates (Blade, JSX, Vue). Skip for backend PHP logic, database queries, API routes, JavaScript with no HTML/CSS component, CSS file audits, build tool configuration, and vanilla CSS.
|
||||||
|
- `medialibrary-development` — Build and work with spatie/laravel-medialibrary features including associating files with Eloquent models, defining media collections and conversions, generating responsive images, and retrieving media URLs and paths.
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
- You must follow all existing code conventions used in this application. When creating or editing a file, check sibling files for the correct structure, approach, and naming.
|
||||||
|
- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`.
|
||||||
|
- Check for existing components to reuse before writing a new one.
|
||||||
|
|
||||||
|
## Verification Scripts
|
||||||
|
|
||||||
|
- Do not create verification scripts or tinker when tests cover that functionality and prove they work. Unit and feature tests are more important.
|
||||||
|
|
||||||
|
## Application Structure & Architecture
|
||||||
|
|
||||||
|
- Stick to existing directory structure; don't create new base folders without approval.
|
||||||
|
- Do not change the application's dependencies without approval.
|
||||||
|
|
||||||
|
## Frontend Bundling
|
||||||
|
|
||||||
|
- If the user doesn't see a frontend change reflected in the UI, it could mean they need to run `npm run build`, `npm run dev`, or `composer run dev`. Ask them.
|
||||||
|
|
||||||
|
## Documentation Files
|
||||||
|
|
||||||
|
- You must only create documentation files if explicitly requested by the user.
|
||||||
|
|
||||||
|
## Replies
|
||||||
|
|
||||||
|
- Be concise in your explanations - focus on what's important rather than explaining obvious details.
|
||||||
|
|
||||||
|
=== boost rules ===
|
||||||
|
|
||||||
|
# Laravel Boost
|
||||||
|
|
||||||
|
- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them.
|
||||||
|
|
||||||
|
## Artisan Commands
|
||||||
|
|
||||||
|
- Run Artisan commands directly via the command line (e.g., `php artisan route:list`, `php artisan tinker --execute "..."`).
|
||||||
|
- Use `php artisan list` to discover available commands and `php artisan [command] --help` to check parameters.
|
||||||
|
|
||||||
|
## URLs
|
||||||
|
|
||||||
|
- Whenever you share a project URL with the user, you should use the `get-absolute-url` tool to ensure you're using the correct scheme, domain/IP, and port.
|
||||||
|
|
||||||
|
## Debugging
|
||||||
|
|
||||||
|
- Use the `database-query` tool when you only need to read from the database.
|
||||||
|
- Use the `database-schema` tool to inspect table structure before writing migrations or models.
|
||||||
|
- To execute PHP code for debugging, run `php artisan tinker --execute "your code here"` directly.
|
||||||
|
- To read configuration values, read the config files directly or run `php artisan config:show [key]`.
|
||||||
|
- To inspect routes, run `php artisan route:list` directly.
|
||||||
|
- To check environment variables, read the `.env` file directly.
|
||||||
|
|
||||||
|
## Reading Browser Logs With the `browser-logs` Tool
|
||||||
|
|
||||||
|
- You can read browser logs, errors, and exceptions using the `browser-logs` tool from Boost.
|
||||||
|
- Only recent browser logs will be useful - ignore old logs.
|
||||||
|
|
||||||
|
## Searching Documentation (Critically Important)
|
||||||
|
|
||||||
|
- Boost comes with a powerful `search-docs` tool you should use before trying other approaches when working with Laravel or Laravel ecosystem packages. This tool automatically passes a list of installed packages and their versions to the remote Boost API, so it returns only version-specific documentation for the user's circumstance. You should pass an array of packages to filter on if you know you need docs for particular packages.
|
||||||
|
- Search the documentation before making code changes to ensure we are taking the correct approach.
|
||||||
|
- Use multiple, broad, simple, topic-based queries at once. For example: `['rate limiting', 'routing rate limiting', 'routing']`. The most relevant results will be returned first.
|
||||||
|
- Do not add package names to queries; package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`.
|
||||||
|
|
||||||
|
### Available Search Syntax
|
||||||
|
|
||||||
|
1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'.
|
||||||
|
2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit".
|
||||||
|
3. Quoted Phrases (Exact Position) - query="infinite scroll" - words must be adjacent and in that order.
|
||||||
|
4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit".
|
||||||
|
5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms.
|
||||||
|
|
||||||
|
=== php rules ===
|
||||||
|
|
||||||
|
# PHP
|
||||||
|
|
||||||
|
- Always use curly braces for control structures, even for single-line bodies.
|
||||||
|
|
||||||
|
## Constructors
|
||||||
|
|
||||||
|
- Use PHP 8 constructor property promotion in `__construct()`.
|
||||||
|
- `public function __construct(public GitHub $github) { }`
|
||||||
|
- Do not allow empty `__construct()` methods with zero parameters unless the constructor is private.
|
||||||
|
|
||||||
|
## Type Declarations
|
||||||
|
|
||||||
|
- Always use explicit return type declarations for methods and functions.
|
||||||
|
- Use appropriate PHP type hints for method parameters.
|
||||||
|
|
||||||
|
<!-- Explicit Return Types and Method Params -->
|
||||||
|
```php
|
||||||
|
protected function isAccessible(User $user, ?string $path = null): bool
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Enums
|
||||||
|
|
||||||
|
- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`.
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
- Prefer PHPDoc blocks over inline comments. Never use comments within the code itself unless the logic is exceptionally complex.
|
||||||
|
|
||||||
|
## PHPDoc Blocks
|
||||||
|
|
||||||
|
- Add useful array shape type definitions when appropriate.
|
||||||
|
|
||||||
|
=== herd rules ===
|
||||||
|
|
||||||
|
# Laravel Herd
|
||||||
|
|
||||||
|
- The application is served by Laravel Herd and will be available at: `https?://[kebab-case-project-dir].test`. Use the `get-absolute-url` tool to generate valid URLs for the user.
|
||||||
|
- You must not run any commands to make the site available via HTTP(S). It is always available through Laravel Herd.
|
||||||
|
|
||||||
|
=== tests rules ===
|
||||||
|
|
||||||
|
# Test Enforcement
|
||||||
|
|
||||||
|
- Every change must be programmatically tested. Write a new test or update an existing test, then run the affected tests to make sure they pass.
|
||||||
|
- Run the minimum number of tests needed to ensure code quality and speed. Use `php artisan test --compact` with a specific filename or filter.
|
||||||
|
|
||||||
|
=== laravel/core rules ===
|
||||||
|
|
||||||
|
# Do Things the Laravel Way
|
||||||
|
|
||||||
|
- Use `php artisan make:` commands to create new files (i.e. migrations, controllers, models, etc.). You can list available Artisan commands using `php artisan list` and check their parameters with `php artisan [command] --help`.
|
||||||
|
- If you're creating a generic PHP class, use `php artisan make:class`.
|
||||||
|
- Pass `--no-interaction` to all Artisan commands to ensure they work without user input. You should also pass the correct `--options` to ensure correct behavior.
|
||||||
|
|
||||||
|
## Database
|
||||||
|
|
||||||
|
- Always use proper Eloquent relationship methods with return type hints. Prefer relationship methods over raw queries or manual joins.
|
||||||
|
- Use Eloquent models and relationships before suggesting raw database queries.
|
||||||
|
- Avoid `DB::`; prefer `Model::query()`. Generate code that leverages Laravel's ORM capabilities rather than bypassing them.
|
||||||
|
- Generate code that prevents N+1 query problems by using eager loading.
|
||||||
|
- Use Laravel's query builder for very complex database operations.
|
||||||
|
|
||||||
|
### Model Creation
|
||||||
|
|
||||||
|
- When creating new models, create useful factories and seeders for them too. Ask the user if they need any other things, using `php artisan make:model --help` to check the available options.
|
||||||
|
|
||||||
|
### APIs & Eloquent Resources
|
||||||
|
|
||||||
|
- For APIs, default to using Eloquent API Resources and API versioning unless existing API routes do not, then you should follow existing application convention.
|
||||||
|
|
||||||
|
## Controllers & Validation
|
||||||
|
|
||||||
|
- Always create Form Request classes for validation rather than inline validation in controllers. Include both validation rules and custom error messages.
|
||||||
|
- Check sibling Form Requests to see if the application uses array or string based validation rules.
|
||||||
|
|
||||||
|
## Authentication & Authorization
|
||||||
|
|
||||||
|
- Use Laravel's built-in authentication and authorization features (gates, policies, Sanctum, etc.).
|
||||||
|
|
||||||
|
## URL Generation
|
||||||
|
|
||||||
|
- When generating links to other pages, prefer named routes and the `route()` function.
|
||||||
|
|
||||||
|
## Queues
|
||||||
|
|
||||||
|
- Use queued jobs for time-consuming operations with the `ShouldQueue` interface.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
- Use environment variables only in configuration files - never use the `env()` function directly outside of config files. Always use `config('app.name')`, not `env('APP_NAME')`.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
- When creating models for tests, use the factories for the models. Check if the factory has custom states that can be used before manually setting up the model.
|
||||||
|
- Faker: Use methods such as `$this->faker->word()` or `fake()->randomDigit()`. Follow existing conventions whether to use `$this->faker` or `fake()`.
|
||||||
|
- When creating tests, make use of `php artisan make:test [options] {name}` to create a feature test, and pass `--unit` to create a unit test. Most tests should be feature tests.
|
||||||
|
|
||||||
|
## Vite Error
|
||||||
|
|
||||||
|
- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `npm run build` or ask the user to run `npm run dev` or `composer run dev`.
|
||||||
|
|
||||||
|
=== pint/core rules ===
|
||||||
|
|
||||||
|
# Laravel Pint Code Formatter
|
||||||
|
|
||||||
|
- If you have modified any PHP files, you must run `vendor/bin/pint --dirty --format agent` before finalizing changes to ensure your code matches the project's expected style.
|
||||||
|
- Do not run `vendor/bin/pint --test --format agent`, simply run `vendor/bin/pint --format agent` to fix any formatting issues.
|
||||||
|
|
||||||
|
=== pest/core rules ===
|
||||||
|
|
||||||
|
## Pest
|
||||||
|
|
||||||
|
- This project uses Pest for testing. Create tests: `php artisan make:test --pest {name}`.
|
||||||
|
- Run tests: `php artisan test --compact` or filter: `php artisan test --compact --filter=testName`.
|
||||||
|
- Do NOT delete tests without approval.
|
||||||
|
|
||||||
|
=== spatie/laravel-medialibrary rules ===
|
||||||
|
|
||||||
|
## Media Library
|
||||||
|
|
||||||
|
- `spatie/laravel-medialibrary` associates files with Eloquent models, with support for collections, conversions, and responsive images.
|
||||||
|
- Always activate the `medialibrary-development` skill when working with media uploads, conversions, collections, responsive images, or any code that uses the `HasMedia` interface or `InteractsWithMedia` trait.
|
||||||
|
|
||||||
|
</laravel-boost-guidelines>
|
||||||
153
_ide_helper.php
153
_ide_helper.php
@@ -24310,157 +24310,6 @@ namespace Spatie\SignalAwareCommand\Facades {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Vinkla\Hashids\Facades {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @method static string encode(mixed ...$numbers)
|
|
||||||
* @method static array decode(string $hash)
|
|
||||||
* @method static string encodeHex(string $str)
|
|
||||||
* @method static string decodeHex(string $hash)
|
|
||||||
*/
|
|
||||||
class Hashids {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function getFactory()
|
|
||||||
{
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
return $instance->getFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a connection instance.
|
|
||||||
*
|
|
||||||
* @param string|null $name
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @return object
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function connection($name = null)
|
|
||||||
{
|
|
||||||
//Method inherited from \GrahamCampbell\Manager\AbstractManager
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
return $instance->connection($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reconnect to the given connection.
|
|
||||||
*
|
|
||||||
* @param string|null $name
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @return object
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function reconnect($name = null)
|
|
||||||
{
|
|
||||||
//Method inherited from \GrahamCampbell\Manager\AbstractManager
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
return $instance->reconnect($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnect from the given connection.
|
|
||||||
*
|
|
||||||
* @param string|null $name
|
|
||||||
* @return void
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function disconnect($name = null)
|
|
||||||
{
|
|
||||||
//Method inherited from \GrahamCampbell\Manager\AbstractManager
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
$instance->disconnect($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the configuration for a connection.
|
|
||||||
*
|
|
||||||
* @param string|null $name
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @return array
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function getConnectionConfig($name = null)
|
|
||||||
{
|
|
||||||
//Method inherited from \GrahamCampbell\Manager\AbstractManager
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
return $instance->getConnectionConfig($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the default connection name.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function getDefaultConnection()
|
|
||||||
{
|
|
||||||
//Method inherited from \GrahamCampbell\Manager\AbstractManager
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
return $instance->getDefaultConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default connection name.
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
* @return void
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function setDefaultConnection($name)
|
|
||||||
{
|
|
||||||
//Method inherited from \GrahamCampbell\Manager\AbstractManager
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
$instance->setDefaultConnection($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register an extension connection resolver.
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
* @param callable $resolver
|
|
||||||
* @return void
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function extend($name, $resolver)
|
|
||||||
{
|
|
||||||
//Method inherited from \GrahamCampbell\Manager\AbstractManager
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
$instance->extend($name, $resolver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return all of the created connections.
|
|
||||||
*
|
|
||||||
* @return array<string,object>
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function getConnections()
|
|
||||||
{
|
|
||||||
//Method inherited from \GrahamCampbell\Manager\AbstractManager
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
return $instance->getConnections();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the config instance.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Contracts\Config\Repository
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function getConfig()
|
|
||||||
{
|
|
||||||
//Method inherited from \GrahamCampbell\Manager\AbstractManager
|
|
||||||
/** @var \Vinkla\Hashids\HashidsManager $instance */
|
|
||||||
return $instance->getConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Illuminate\Http {
|
namespace Illuminate\Http {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -28936,7 +28785,7 @@ namespace {
|
|||||||
class Bouncer extends \Silber\Bouncer\BouncerFacade {}
|
class Bouncer extends \Silber\Bouncer\BouncerFacade {}
|
||||||
class Flare extends \Spatie\LaravelIgnition\Facades\Flare {}
|
class Flare extends \Spatie\LaravelIgnition\Facades\Flare {}
|
||||||
class Signal extends \Spatie\SignalAwareCommand\Facades\Signal {}
|
class Signal extends \Spatie\SignalAwareCommand\Facades\Signal {}
|
||||||
class Hashids extends \Vinkla\Hashids\Facades\Hashids {}
|
class Hashids extends \App\Facades\Hashids {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
22
app/Facades/Hashids.php
Normal file
22
app/Facades/Hashids.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Facades;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method static string encode(mixed ...$numbers)
|
||||||
|
* @method static array decode(string $hash)
|
||||||
|
* @method static string encodeHex(string $str)
|
||||||
|
* @method static string decodeHex(string $hash)
|
||||||
|
* @method static \Hashids\Hashids connection(string|null $name = null)
|
||||||
|
*/
|
||||||
|
class Hashids extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor(): string
|
||||||
|
{
|
||||||
|
return 'hashids';
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Hashids/HashidsFactory.php
Normal file
35
app/Hashids/HashidsFactory.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Hashids;
|
||||||
|
|
||||||
|
use Hashids\Hashids;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
class HashidsFactory
|
||||||
|
{
|
||||||
|
public function make(array $config): Hashids
|
||||||
|
{
|
||||||
|
$config = $this->getConfig($config);
|
||||||
|
|
||||||
|
return $this->getClient($config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{salt: string, length: int, alphabet: string}
|
||||||
|
*/
|
||||||
|
protected function getConfig(array $config): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'salt' => Arr::get($config, 'salt', ''),
|
||||||
|
'length' => Arr::get($config, 'length', 0),
|
||||||
|
'alphabet' => Arr::get($config, 'alphabet', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getClient(array $config): Hashids
|
||||||
|
{
|
||||||
|
return new Hashids($config['salt'], $config['length'], $config['alphabet']);
|
||||||
|
}
|
||||||
|
}
|
||||||
72
app/Hashids/HashidsManager.php
Normal file
72
app/Hashids/HashidsManager.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Hashids;
|
||||||
|
|
||||||
|
use Hashids\Hashids;
|
||||||
|
use Illuminate\Contracts\Config\Repository;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves named Hashids clients from config/hashids.php (one "connection" per model class).
|
||||||
|
*
|
||||||
|
* @method string encode(mixed ...$numbers)
|
||||||
|
* @method array decode(string $hash)
|
||||||
|
* @method string encodeHex(string $str)
|
||||||
|
* @method string decodeHex(string $hash)
|
||||||
|
*/
|
||||||
|
class HashidsManager
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array<string, Hashids>
|
||||||
|
*/
|
||||||
|
protected array $connections = [];
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
protected Repository $config,
|
||||||
|
protected HashidsFactory $factory
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function connection(?string $name = null): Hashids
|
||||||
|
{
|
||||||
|
$name = $name ?? $this->getDefaultConnection();
|
||||||
|
|
||||||
|
if (! isset($this->connections[$name])) {
|
||||||
|
$this->connections[$name] = $this->factory->make(
|
||||||
|
$this->getConnectionConfig($name)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->connections[$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDefaultConnection(): string
|
||||||
|
{
|
||||||
|
return (string) $this->config->get('hashids.default');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFactory(): HashidsFactory
|
||||||
|
{
|
||||||
|
return $this->factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
protected function getConnectionConfig(string $name): array
|
||||||
|
{
|
||||||
|
$connections = $this->config->get('hashids.connections', []);
|
||||||
|
|
||||||
|
if (! is_array($connections) || ! isset($connections[$name])) {
|
||||||
|
throw new InvalidArgumentException("Hashids connection [{$name}] not configured.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $connections[$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __call(string $method, array $parameters): mixed
|
||||||
|
{
|
||||||
|
return $this->connection()->$method(...$parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
45
app/Hashids/HashidsServiceProvider.php
Normal file
45
app/Hashids/HashidsServiceProvider.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Hashids;
|
||||||
|
|
||||||
|
use Hashids\Hashids as HashidsClient;
|
||||||
|
use Illuminate\Contracts\Container\Container;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class HashidsServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
$this->app->singleton('hashids.factory', function () {
|
||||||
|
return new HashidsFactory;
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->alias('hashids.factory', HashidsFactory::class);
|
||||||
|
|
||||||
|
$this->app->singleton('hashids', function (Container $app) {
|
||||||
|
return new HashidsManager($app['config'], $app['hashids.factory']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->alias('hashids', HashidsManager::class);
|
||||||
|
|
||||||
|
$this->app->bind('hashids.connection', function (Container $app) {
|
||||||
|
return $app['hashids']->connection();
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->alias('hashids.connection', HashidsClient::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function provides(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'hashids',
|
||||||
|
'hashids.factory',
|
||||||
|
'hashids.connection',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\V1\Admin\Company;
|
namespace App\Http\Controllers\V1\Admin\Company;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\CompaniesRequest;
|
use App\Http\Requests\CompaniesRequest;
|
||||||
use App\Http\Resources\CompanyResource;
|
use App\Http\Resources\CompanyResource;
|
||||||
@@ -9,7 +10,6 @@ use App\Models\Company;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Silber\Bouncer\BouncerFacade;
|
use Silber\Bouncer\BouncerFacade;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class CompaniesController extends Controller
|
class CompaniesController extends Controller
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,21 +2,22 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\V1\Admin\Estimate;
|
namespace App\Http\Controllers\V1\Admin\Estimate;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\EstimateResource;
|
use App\Http\Resources\EstimateResource;
|
||||||
use App\Models\CompanySetting;
|
use App\Models\CompanySetting;
|
||||||
use App\Models\Estimate;
|
use App\Models\Estimate;
|
||||||
use App\Services\SerialNumberFormatter;
|
use App\Services\SerialNumberFormatter;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class CloneEstimateController extends Controller
|
class CloneEstimateController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Mail a specific invoice to the corresponding customer's email address.
|
* Mail a specific invoice to the corresponding customer's email address.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function __invoke(Request $request, Estimate $estimate)
|
public function __invoke(Request $request, Estimate $estimate)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\V1\Admin\Estimate;
|
namespace App\Http\Controllers\V1\Admin\Estimate;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\InvoiceResource;
|
use App\Http\Resources\InvoiceResource;
|
||||||
use App\Models\CompanySetting;
|
use App\Models\CompanySetting;
|
||||||
@@ -10,15 +11,15 @@ use App\Models\Invoice;
|
|||||||
use App\Services\SerialNumberFormatter;
|
use App\Services\SerialNumberFormatter;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class ConvertEstimateController extends Controller
|
class ConvertEstimateController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle the incoming request.
|
* Handle the incoming request.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function __invoke(Request $request, Estimate $estimate, Invoice $invoice)
|
public function __invoke(Request $request, Estimate $estimate, Invoice $invoice)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,21 +2,22 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\V1\Admin\Invoice;
|
namespace App\Http\Controllers\V1\Admin\Invoice;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\InvoiceResource;
|
use App\Http\Resources\InvoiceResource;
|
||||||
use App\Models\CompanySetting;
|
use App\Models\CompanySetting;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Services\SerialNumberFormatter;
|
use App\Services\SerialNumberFormatter;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class CloneInvoiceController extends Controller
|
class CloneInvoiceController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Mail a specific invoice to the corresponding customer's email address.
|
* Mail a specific invoice to the corresponding customer's email address.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function __invoke(Request $request, Invoice $invoice)
|
public function __invoke(Request $request, Invoice $invoice)
|
||||||
{
|
{
|
||||||
|
|||||||
20
app/Http/Middleware/CustomerGuest.php
Normal file
20
app/Http/Middleware/CustomerGuest.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class CustomerGuest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Guest-only routes for the customer guard (same behavior as {@see CustomerRedirectIfAuthenticated}).
|
||||||
|
*
|
||||||
|
* @param Closure(Request): (Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next, ?string $guard = null): Response
|
||||||
|
{
|
||||||
|
return app(CustomerRedirectIfAuthenticated::class)->handle($request, $next, $guard);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Http/Middleware/CustomerRedirectIfAuthenticated.php
Normal file
28
app/Http/Middleware/CustomerRedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class CustomerRedirectIfAuthenticated
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Redirect customers away from "guest" routes (e.g. login) when already authenticated.
|
||||||
|
*
|
||||||
|
* @param Closure(Request): (Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next, ?string $guard = null): Response
|
||||||
|
{
|
||||||
|
$guard ??= 'customer';
|
||||||
|
|
||||||
|
if (Auth::guard($guard)->check()) {
|
||||||
|
return redirect()->to(RouteServiceProvider::CUSTOMER_HOME);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery as Middleware;
|
||||||
|
|
||||||
class VerifyCsrfToken extends Middleware
|
class PreventRequestForgery extends Middleware
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
|
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
|
||||||
@@ -16,7 +16,7 @@ class VerifyCsrfToken extends Middleware
|
|||||||
/**
|
/**
|
||||||
* The URIs that should be excluded from CSRF verification.
|
* The URIs that should be excluded from CSRF verification.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
'login',
|
'login',
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Mail;
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Models\EmailLog;
|
use App\Models\EmailLog;
|
||||||
use App\Models\Estimate;
|
use App\Models\Estimate;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class SendEstimateMail extends Mailable
|
class SendEstimateMail extends Mailable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Mail;
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Models\EmailLog;
|
use App\Models\EmailLog;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class SendInvoiceMail extends Mailable
|
class SendInvoiceMail extends Mailable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Mail;
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Models\EmailLog;
|
use App\Models\EmailLog;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class SendPaymentMail extends Mailable
|
class SendPaymentMail extends Mailable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App;
|
use App;
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Facades\PDF;
|
use App\Facades\PDF;
|
||||||
use App\Mail\SendEstimateMail;
|
use App\Mail\SendEstimateMail;
|
||||||
use App\Services\SerialNumberFormatter;
|
use App\Services\SerialNumberFormatter;
|
||||||
@@ -18,7 +19,6 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Spatie\MediaLibrary\HasMedia;
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class Estimate extends Model implements HasMedia
|
class Estimate extends Model implements HasMedia
|
||||||
{
|
{
|
||||||
@@ -79,7 +79,7 @@ class Estimate extends Model implements HasMedia
|
|||||||
|
|
||||||
public function items(): HasMany
|
public function items(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(\App\Models\EstimateItem::class);
|
return $this->hasMany(EstimateItem::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customer(): BelongsTo
|
public function customer(): BelongsTo
|
||||||
@@ -89,12 +89,12 @@ class Estimate extends Model implements HasMedia
|
|||||||
|
|
||||||
public function creator(): BelongsTo
|
public function creator(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(\App\Models\User::class, 'creator_id');
|
return $this->belongsTo(User::class, 'creator_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function company(): BelongsTo
|
public function company(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(\App\Models\Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function currency(): BelongsTo
|
public function currency(): BelongsTo
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App;
|
use App;
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Facades\PDF;
|
use App\Facades\PDF;
|
||||||
use App\Mail\SendInvoiceMail;
|
use App\Mail\SendInvoiceMail;
|
||||||
use App\Services\SerialNumberFormatter;
|
use App\Services\SerialNumberFormatter;
|
||||||
@@ -18,7 +19,6 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|||||||
use Nwidart\Modules\Facades\Module;
|
use Nwidart\Modules\Facades\Module;
|
||||||
use Spatie\MediaLibrary\HasMedia;
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class Invoice extends Model implements HasMedia
|
class Invoice extends Model implements HasMedia
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@ class Invoice extends Model implements HasMedia
|
|||||||
|
|
||||||
public function items(): HasMany
|
public function items(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(\App\Models\InvoiceItem::class);
|
return $this->hasMany(InvoiceItem::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function taxes(): HasMany
|
public function taxes(): HasMany
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Jobs\GeneratePaymentPdfJob;
|
use App\Jobs\GeneratePaymentPdfJob;
|
||||||
use App\Mail\SendPaymentMail;
|
use App\Mail\SendPaymentMail;
|
||||||
use App\Services\SerialNumberFormatter;
|
use App\Services\SerialNumberFormatter;
|
||||||
@@ -15,7 +16,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
use Spatie\MediaLibrary\HasMedia;
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class Payment extends Model implements HasMedia
|
class Payment extends Model implements HasMedia
|
||||||
{
|
{
|
||||||
@@ -116,7 +116,7 @@ class Payment extends Model implements HasMedia
|
|||||||
|
|
||||||
public function creator(): BelongsTo
|
public function creator(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(\App\Models\User::class, 'creator_id');
|
return $this->belongsTo(User::class, 'creator_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function currency(): BelongsTo
|
public function currency(): BelongsTo
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Http\Requests\RecurringInvoiceRequest;
|
use App\Http\Requests\RecurringInvoiceRequest;
|
||||||
use App\Services\SerialNumberFormatter;
|
use App\Services\SerialNumberFormatter;
|
||||||
use App\Traits\HasCustomFieldsTrait;
|
use App\Traits\HasCustomFieldsTrait;
|
||||||
@@ -11,7 +12,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class RecurringInvoice extends Model
|
class RecurringInvoice extends Model
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class Transaction extends Model
|
class Transaction extends Model
|
||||||
{
|
{
|
||||||
|
|||||||
18
boost.json
Normal file
18
boost.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"agents": [
|
||||||
|
"cursor"
|
||||||
|
],
|
||||||
|
"guidelines": true,
|
||||||
|
"herd_mcp": false,
|
||||||
|
"mcp": true,
|
||||||
|
"nightwatch_mcp": false,
|
||||||
|
"packages": [
|
||||||
|
"spatie/laravel-medialibrary"
|
||||||
|
],
|
||||||
|
"sail": false,
|
||||||
|
"skills": [
|
||||||
|
"pest-testing",
|
||||||
|
"tailwindcss-development",
|
||||||
|
"medialibrary-development"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,13 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Middleware\Authenticate;
|
||||||
|
use App\Http\Middleware\CompanyMiddleware;
|
||||||
|
use App\Http\Middleware\ConfigMiddleware;
|
||||||
|
use App\Http\Middleware\CronJobMiddleware;
|
||||||
|
use App\Http\Middleware\CustomerGuest;
|
||||||
|
use App\Http\Middleware\CustomerPortalMiddleware;
|
||||||
|
use App\Http\Middleware\CustomerRedirectIfAuthenticated;
|
||||||
|
use App\Http\Middleware\EncryptCookies;
|
||||||
|
use App\Http\Middleware\InstallationMiddleware;
|
||||||
|
use App\Http\Middleware\PdfMiddleware;
|
||||||
|
use App\Http\Middleware\PreventRequestForgery;
|
||||||
|
use App\Http\Middleware\RedirectIfAuthenticated;
|
||||||
|
use App\Http\Middleware\RedirectIfInstalled;
|
||||||
|
use App\Http\Middleware\RedirectIfUnauthorized;
|
||||||
|
use App\Http\Middleware\ScopeBouncer;
|
||||||
|
use App\Http\Middleware\TrimStrings;
|
||||||
|
use App\Http\Middleware\TrustProxies;
|
||||||
use App\Providers\AppServiceProvider;
|
use App\Providers\AppServiceProvider;
|
||||||
|
use Illuminate\Auth\Middleware\Authorize;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Foundation\Configuration\Exceptions;
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
use Illuminate\Foundation\Configuration\Middleware;
|
use Illuminate\Foundation\Configuration\Middleware;
|
||||||
|
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
|
||||||
|
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||||
|
use Illuminate\Session\Middleware\AuthenticateSession;
|
||||||
|
use Illuminate\Session\Middleware\StartSession;
|
||||||
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
|
use Lavary\Menu\ServiceProvider;
|
||||||
|
|
||||||
return Application::configure(basePath: dirname(__DIR__))
|
return Application::configure(basePath: dirname(__DIR__))
|
||||||
->withProviders([
|
->withProviders([
|
||||||
\Lavary\Menu\ServiceProvider::class,
|
ServiceProvider::class,
|
||||||
])
|
])
|
||||||
->withRouting(
|
->withRouting(
|
||||||
web: __DIR__.'/../routes/web.php',
|
web: __DIR__.'/../routes/web.php',
|
||||||
@@ -20,52 +44,52 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||||||
$middleware->redirectGuestsTo(fn () => route('login'));
|
$middleware->redirectGuestsTo(fn () => route('login'));
|
||||||
$middleware->redirectUsersTo(AppServiceProvider::HOME);
|
$middleware->redirectUsersTo(AppServiceProvider::HOME);
|
||||||
|
|
||||||
$middleware->validateCsrfTokens(except: [
|
$middleware->preventRequestForgery(except: [
|
||||||
'login',
|
'login',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$middleware->append([
|
$middleware->append([
|
||||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
CheckForMaintenanceMode::class,
|
||||||
\App\Http\Middleware\TrimStrings::class,
|
TrimStrings::class,
|
||||||
\App\Http\Middleware\TrustProxies::class,
|
TrustProxies::class,
|
||||||
\App\Http\Middleware\ConfigMiddleware::class,
|
ConfigMiddleware::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$middleware->web([
|
$middleware->web([
|
||||||
\App\Http\Middleware\EncryptCookies::class,
|
EncryptCookies::class,
|
||||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
PreventRequestForgery::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$middleware->statefulApi();
|
$middleware->statefulApi();
|
||||||
$middleware->throttleApi('180,1');
|
$middleware->throttleApi('180,1');
|
||||||
|
|
||||||
$middleware->replace(\Illuminate\Http\Middleware\TrustProxies::class, \App\Http\Middleware\TrustProxies::class);
|
$middleware->replace(Illuminate\Http\Middleware\TrustProxies::class, TrustProxies::class);
|
||||||
|
|
||||||
$middleware->replaceInGroup('web', \Illuminate\Cookie\Middleware\EncryptCookies::class, \App\Http\Middleware\EncryptCookies::class);
|
$middleware->replaceInGroup('web', Illuminate\Cookie\Middleware\EncryptCookies::class, EncryptCookies::class);
|
||||||
|
|
||||||
$middleware->alias([
|
$middleware->alias([
|
||||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
'auth' => Authenticate::class,
|
||||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
'bindings' => SubstituteBindings::class,
|
||||||
'bouncer' => \App\Http\Middleware\ScopeBouncer::class,
|
'bouncer' => ScopeBouncer::class,
|
||||||
'company' => \App\Http\Middleware\CompanyMiddleware::class,
|
'company' => CompanyMiddleware::class,
|
||||||
'cron-job' => \App\Http\Middleware\CronJobMiddleware::class,
|
'cron-job' => CronJobMiddleware::class,
|
||||||
'customer' => \App\Http\Middleware\CustomerRedirectIfAuthenticated::class,
|
'customer' => CustomerRedirectIfAuthenticated::class,
|
||||||
'customer-guest' => \App\Http\Middleware\CustomerGuest::class,
|
'customer-guest' => CustomerGuest::class,
|
||||||
'customer-portal' => \App\Http\Middleware\CustomerPortalMiddleware::class,
|
'customer-portal' => CustomerPortalMiddleware::class,
|
||||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
'guest' => RedirectIfAuthenticated::class,
|
||||||
'install' => \App\Http\Middleware\InstallationMiddleware::class,
|
'install' => InstallationMiddleware::class,
|
||||||
'pdf-auth' => \App\Http\Middleware\PdfMiddleware::class,
|
'pdf-auth' => PdfMiddleware::class,
|
||||||
'redirect-if-installed' => \App\Http\Middleware\RedirectIfInstalled::class,
|
'redirect-if-installed' => RedirectIfInstalled::class,
|
||||||
'redirect-if-unauthenticated' => \App\Http\Middleware\RedirectIfUnauthorized::class,
|
'redirect-if-unauthenticated' => RedirectIfUnauthorized::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$middleware->priority([
|
$middleware->priority([
|
||||||
\Illuminate\Session\Middleware\StartSession::class,
|
StartSession::class,
|
||||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
\App\Http\Middleware\Authenticate::class,
|
Authenticate::class,
|
||||||
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
AuthenticateSession::class,
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
SubstituteBindings::class,
|
||||||
\Illuminate\Auth\Middleware\Authorize::class,
|
Authorize::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Hashids\HashidsServiceProvider;
|
||||||
|
use App\Providers\AppConfigProvider;
|
||||||
|
use App\Providers\AppServiceProvider;
|
||||||
|
use App\Providers\DropboxServiceProvider;
|
||||||
|
use App\Providers\PDFServiceProvider;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use App\Providers\ViewServiceProvider;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
App\Providers\AppServiceProvider::class,
|
HashidsServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
AppServiceProvider::class,
|
||||||
App\Providers\DropboxServiceProvider::class,
|
RouteServiceProvider::class,
|
||||||
App\Providers\ViewServiceProvider::class,
|
DropboxServiceProvider::class,
|
||||||
App\Providers\PDFServiceProvider::class,
|
ViewServiceProvider::class,
|
||||||
App\Providers\AppConfigProvider::class,
|
PDFServiceProvider::class,
|
||||||
|
AppConfigProvider::class,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -8,43 +8,43 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.3",
|
||||||
"aws/aws-sdk-php": "^3.336",
|
"aws/aws-sdk-php": "^3.336",
|
||||||
"barryvdh/laravel-dompdf": "^v3.0",
|
"barryvdh/laravel-dompdf": "^v3.0",
|
||||||
"doctrine/dbal": "^4.2",
|
"doctrine/dbal": "^4.2",
|
||||||
"dragonmantank/cron-expression": "^v3.4",
|
"dragonmantank/cron-expression": "^v3.4",
|
||||||
"gotenberg/gotenberg-php": "^2.8",
|
"gotenberg/gotenberg-php": "^2.8",
|
||||||
"guzzlehttp/guzzle": "^7.9",
|
"guzzlehttp/guzzle": "^7.9",
|
||||||
|
"hashids/hashids": "^5.0",
|
||||||
"invoiceshelf/modules": "^1.0.0",
|
"invoiceshelf/modules": "^1.0.0",
|
||||||
"jasonmccreary/laravel-test-assertions": "^v2.4",
|
"jasonmccreary/laravel-test-assertions": "^v2.4",
|
||||||
"laravel/framework": "^12.0",
|
"laravel/framework": "^13.0",
|
||||||
"laravel/helpers": "^1.7",
|
"laravel/helpers": "^1.7",
|
||||||
"laravel/sanctum": "^4.0",
|
"laravel/sanctum": "^4.0",
|
||||||
"laravel/tinker": "^2.10.1",
|
"laravel/tinker": "^3.0",
|
||||||
"laravel/ui": "^4.6",
|
"laravel/ui": "^4.6",
|
||||||
"lavary/laravel-menu": "^1.8",
|
"lavary/laravel-menu": "^1.8",
|
||||||
"league/flysystem-aws-s3-v3": "^3.29",
|
"league/flysystem-aws-s3-v3": "^3.29",
|
||||||
"predis/predis": "^2.3",
|
"predis/predis": "^2.3",
|
||||||
"silber/bouncer": "v1.0.3",
|
"silber/bouncer": "^1.0.4",
|
||||||
"spatie/flysystem-dropbox": "^3.0",
|
"spatie/flysystem-dropbox": "^3.0",
|
||||||
"spatie/laravel-backup": "^9.2.9",
|
"spatie/laravel-backup": "^10.0",
|
||||||
"spatie/laravel-medialibrary": "^11.11",
|
"spatie/laravel-medialibrary": "^11.11",
|
||||||
"symfony/mailer": "^7.3",
|
"symfony/mailer": "^7.3",
|
||||||
"symfony/mailgun-mailer": "^7.3",
|
"symfony/mailgun-mailer": "^7.3"
|
||||||
"vinkla/hashids": "^13.0.0"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"barryvdh/laravel-ide-helper": "^3.5",
|
"barryvdh/laravel-ide-helper": "^3.5",
|
||||||
"beyondcode/laravel-dump-server": "^2.0.0",
|
|
||||||
"fakerphp/faker": "^1.23",
|
"fakerphp/faker": "^1.23",
|
||||||
|
"laravel/boost": "^2.3",
|
||||||
"laravel/pint": "^1.13",
|
"laravel/pint": "^1.13",
|
||||||
"laravel/sail": "^1.41",
|
"laravel/sail": "^1.41",
|
||||||
"mockery/mockery": "^1.6",
|
"mockery/mockery": "^1.6",
|
||||||
"nunomaduro/collision": "^8.6",
|
"nunomaduro/collision": "^8.6",
|
||||||
"pestphp/pest": "^3.8",
|
"pestphp/pest": "^4.0",
|
||||||
"pestphp/pest-plugin-faker": "^3.0",
|
"pestphp/pest-plugin-faker": "^4.0",
|
||||||
"pestphp/pest-plugin-laravel": "^3.1",
|
"pestphp/pest-plugin-laravel": "^4.0",
|
||||||
"phpunit/phpunit": "^11.5.3",
|
"phpunit/phpunit": "^12.0",
|
||||||
"spatie/laravel-ignition": "^2.9"
|
"spatie/laravel-ignition": "^2.9"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -69,7 +69,8 @@
|
|||||||
"@php artisan package:discover --ansi"
|
"@php artisan package:discover --ansi"
|
||||||
],
|
],
|
||||||
"post-update-cmd": [
|
"post-update-cmd": [
|
||||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
"@php artisan vendor:publish --tag=laravel-assets --ansi --force",
|
||||||
|
"@php artisan boost:update --ansi"
|
||||||
],
|
],
|
||||||
"post-root-package-install": [
|
"post-root-package-install": [
|
||||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
|||||||
4188
composer.lock
generated
4188
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright (c) Vincent Klaiber.
|
* Hashids connection config (per model class).
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* Wired by App\Hashids\HashidsServiceProvider using the hashids/hashids package.
|
||||||
* file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://github.com/vinkla/laravel-hashids
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\CompanySetting;
|
use App\Models\CompanySetting;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
@@ -10,7 +11,6 @@ use App\Models\User;
|
|||||||
use App\Space\InstallUtils;
|
use App\Space\InstallUtils;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Silber\Bouncer\BouncerFacade;
|
use Silber\Bouncer\BouncerFacade;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class DemoSeeder extends Seeder
|
class DemoSeeder extends Seeder
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Facades\Hashids;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Space\InstallUtils;
|
use App\Space\InstallUtils;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Silber\Bouncer\BouncerFacade;
|
use Silber\Bouncer\BouncerFacade;
|
||||||
use Vinkla\Hashids\Facades\Hashids;
|
|
||||||
|
|
||||||
class UsersTableSeeder extends Seeder
|
class UsersTableSeeder extends Seeder
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user