Packaged version of the recreate gallery project
- PHP ^8.1
- Laravel 9 and up
- GD Library *
composer require lisa-fehr/gallery
Command | Description |
---|---|
php artisan storage:link |
Connect the [public/storage] link to [storage/app/public] |
php artisan gallery:install |
Publish Gallery Assets and Config. Gives access to the gallery vue components. Can use gallery-originals and gallery filesystems. Adds a gallery file under /config for custom routes |
php artisan images:generate |
Creates the missing image placeholders. Place images under storage/gallery in a nested folder structure like: Photos/California, {parent} /{tag} |
<link rel="stylesheet" href="{{ asset('vendor/lisa-fehr/gallery/css/app.css') }}" type="text/css" media="screen"/>
...
<script src="{{mix('js/app.js', 'vendor/lisa-fehr/gallery')}}"></script>
<div id="gallery-app" class="text-sm w-full" data-filters="{{$filter['tags'] ?? ''}}"></div>
You can also override routes with inconsistent patterns:
{
"tag": "path from root - no starting slash needed"
}
<div id="gallery-app" class="text-sm w-full"
data-filters="{{$filter['tags'] ?? ''}}"
data-routes='{"portfolio":"portfolio","Folder2005":"Folder\/2005"}'
></div>
The landing page doesn't take any filters and should show everything.
Route::get('portfolio', function () {
return view('portfolio');
})->name('portfolio');
Additional pages: Route name must match the name
field in the uber_tags
table. Must include the current tag at the beginning.
Route::get('photos', function () {
return view('portfolio')
->with('filter', [
'tags' => 'photos,California,California2005,California2009,California2014'
]);
})->name('photos');
Or use the Tag model to get all the children:
Route::get('California', function () {
$children = UberTags::where('name', 'california')->allChildren()->pluck('name')->implode(',');
return view('portfolio')
->with('filter', [
'tags' => 'california,' . $children
]);
})->name('California');
If the named route for the tag doesn't exist, it will not show up in navigation to prevent broken links.
Run the migrations
php artisan migrate --path=vendor/lisa-fehr/gallery/src/database/migrations
Run the seeders
php artisan db:seed --class=LisaFehr\\Gallery\\Database\\Seeders\\GalleryDatabaseSeeder
- Check that the
APP_URL
in the .env is correct. IE: Contains the port number. - Make sure these were run:
php artisan storage:link
andphp artisan images:generate
Illuminate\Database\QueryException SQLSTATE[HY000]: General error: 1 HAVING clause on a non-aggregate query
Don't use sqlite. Check the .env file and fill in:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=