Appearance
Record covers
- Every record has a cover image that is stored locally in the /storage/covers directory
- As you may have noticed, there is no
cover
column in therecords
table - The name of the image refers to the record's
mb_id
column
E.g. if themb_id
value isf0a4ed57-10e0-4c37-81b4-36311dc7d4b6
, the cover image must bef0a4ed57-10e0-4c37-81b4-36311dc7d4b6.jpg
- Later on in the course, we discuss some scripts to upload, replace and delete cover images
- To start using the covers, we prepared a small script to download a zip file containing all the covers and store them locally in the right folder
Create a symlink to the storage directory
- If you followed all the instructions when starting up our project, the symlink should already be created
- If not, you can create it by running the following command in your terminal:
php artisan storage:link
link already exists
- If you execute the
php artisan storage:link
more than once, you get the following error: - You can ignore this error, as the link was already created during the initial startup of the project
Download the covers
REMARKS
- The script we prepared is written in "pure PHP" and does not use much of the Laravel framework, therefore we will not discuss this code in detail
- Because this script is only used to speed up the development process, we will not add it to the navigation menu
- Later on, you can re-run this script every time you need to reset to the default covers
- Create a new file download_covers.blade.php inside the resources/views/admin directory
- Create a route to the download_covers page in routes/web.php
- Add a new route to the admin section in routes/web.php
php
Route::prefix('admin')->name('admin.')->group(function () {
Route::redirect('/', '/admin/records');
Route::get('records', function (){...})->name('records');
Route::view('download_covers', 'admin.download_covers')->name('download_covers');
});
1
2
3
4
5
2
3
4
5
- Run the script by opening the url http://vinyl_shop.test/admin/download_covers in your browser
- Because of the symlink, the covers will be visible in the storage/app/public/covers directory and in the public/storage/covers directory
- Open the url http://vinyl_shop.test/storage/covers/f0a4ed57-10e0-4c37-81b4-36311dc7d4b6.jpg to check one of the covers
covers folder not visible
- It might be possible that the
covers
folder doesn't appear in PhpStorm. - Try to right-click the
storage/app/public
folder and chooseReload from Disk
to force your working directory to refresh