Helpful Youtube Videos:

https://www.youtube.com/watch?v=FeIYurxiggU
GitHub Code: https://github.com/codewithtonyofficial/laravel-medialibrary

https://www.youtube.com/watch?v=ex0o2eRhtp4&list=PLe30vg_FG4OQ47ovsjgSSX5BZy_kqbuTO&index=13
Not Github Code Found

My Notes

NOTES SOURCE: /g/APPS/REACT/OVERIMAGE/V5/LARAVEL/Laravel Media Library Full Tutorial  Laravel 9 Tutorial/media
 
https://www.youtube.com/watch?v=FeIYurxiggU
 Laravel Media Library Full Tutorial | Laravel 9 Tutorial

1. Create new laravel project
$ composer create-project --prefer-dist laravel/laravel media
$ code media
$ php artisan serve

http://127.0.0.1:8000

2. PREP DATABASE
update env file and create database; aravel_media_library
http://localhost:8080/phpmyadmin/index.php?route=/database/structure&db=laravel_media_library

AFTER ADD MYSQL TABLE: phpmyadmin open .env
DB_DATABASE=laravel_media_library
DB_USERNAME=root
DB_PASSWORD=

https://spatie.be/docs/laravel-medialibrary/v10/introduction
https://spatie.be/docs/laravel-medialibrary/v10/installation-setup
https://ahmedshaltout.com/laravel/how-to-upload-retrieve-images-by-laravel-media-library/
How to upload & retrieve images by Laravel media library

3. Base installation
$ composer require "spatie/laravel-medialibrary:^10.0.0"
Preparing the database
$ php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"
$ ls database/migrations/
COPY FILE NAME AND REPLACE IT IN THE FOLLOWING COMMAND: (NO WILD CARDS ALLOWED)

$ php artisan migrate:refresh --path=/database/migrations/[fileName].php


4. Publishing the config file
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="config"
# OPEN CONFIG FILE AND CHANGE ACCODINGLY. BUT LEAVE AS IS FOR NOW
$ code config/media-library.php
https://youtu.be/FeIYurxiggU?t=231

5. Preparing your model
https://youtu.be/FeIYurxiggU?t=259
https://spatie.be/docs/laravel-medialibrary/v10/basic-usage/preparing-your-model
$ php artisan make:model Post -m
OPEN Models/Post.php
$ code app/Models/Post.php
$ Change the entire code for Post.php to be exactly as app/Models/Post.php from the following URL page:
https://www.webune.com/forums/very-simple-code-for-adding-files-laravel-media-library-spatie.html
 
$ code database/migrations/*_create_posts_table.php
ADD: after  $table->id();
            $table->string('title');
            $table->text('body');
 
6. $ ls database/migrations/*_posts*.php
COPY FILE NAME AND REPLACE IT IN THE FOLLOWING COMMAND: (NO WILD CARDS ALLOWED)

$ php artisan migrate:refresh --path=database/migrations/[fileName].php
# CONFIRM YOU NOW HAVE THE post TABLE:
http://localhost:8080/phpmyadmin/index.php?route=/sql&db=laravel_media_library&table=posts&pos=0

7. add PostController
$ php artisan make:controller Api/PostController
$ code app/Http/Controllers/Api/PostController.php
COPY THE METHODS FROM THIS POSTS FOR YOUR CONTORLLER AS AN EXAMPLE:
URL: https://www.webune.com/forums/very-simple-code-for-adding-files-laravel-media-library-spatie.html
File Name In the Page: app\Http\Controllers\Api\FileController.php
Example Basic to create post:
    public function create()
    {
        return view('posts.create');
    }

8. Add PostStoreRequest.php
$ php artisan make:request PostStoreRequest
$ code app/Http/Requests/PostStoreRequest.php
GO TO THIS URL AND MAKE IT SIMILAR TO StoreFileRequest.php FROM THIS POST:
URL: https://www.webune.com/forums/very-simple-code-for-adding-files-laravel-media-library-spatie.html
* IMPORTANT: MAKE SURE TO CHANGE authorized() to return true for the API to work.
Be sure to add to PostStoreRequest.php
use App\Http\Requests\Files\StoreFileRequest;

8. api.php ADD ROUTES AND CONROLLER
https://youtu.be/FeIYurxiggU?t=381
https://youtu.be/FeIYurxiggU?t=420
$ code routes/api.php
ADD: Route::apiResource('/posts', PostController::class);

9. TEST API WIH POSTMAN:
YOU CAN COPY THE ENDPOINT FROM THE IMAGE ON THIS POST TO SEE THE PARAMETERS TO SEND TO THE API FROM POSTMAN:
https://www.webune.com/forums/very-simple-code-for-adding-files-laravel-media-library-spatie.html
 
I GOT THIS ERROR:
Intervention\Image\Exception\NotSupportedException: GD Library extension not available with this PHP installation. in file F:\apachefriends\xampp\htdocs\over-imgV5\REACT\MYOWN\IONIC\BACKEND-laravel-api-template\laravel-api-upload\vendor\intervention\image
 
SOLUTION: https://www.webune.com/forums/solved-laravel-gd-library-extension-not-available-with-this-php-installation.html
 
Good Luck.
 
############################################ STOP HERE ##################
 # THE REST ARE FRONT END NOTES WHICH DID NOT WORK 
$ mkdir resources/views/components
$ curl -o resources/views/components/main.blade.php https://raw.githubusercontent.com/codewithtonyofficial/laravel-medialibrary/main/resources/views/components/main.blade.php
code resources/views/components/main.blade.php

mkdir resources/views/posts
curl -o resources/views/posts/create.blade.php https://raw.githubusercontent.com/codewithtonyofficial/laravel-medialibrary/main/resources/views/posts/create.blade.php
code resources/views/posts/create.blade.php


https://stackoverflow.com/a/26541680
php artisan make:request Files/CreateFileRequest