Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Can MediaMan be integrated with Livewire or InertiaJS


Can MediaMan be integrated with Livewire or InertiaJS


Yes, MediaMan can be integrated with both Livewire and Inertia.js. Here are some general steps to integrate MediaMan with these frameworks:

Integrating MediaMan with Livewire

1. Install MediaMan:

bash
   composer require farhanshares/laravel-mediaman
   

2. Publish Configuration Files:

bash
   php artisan mediaman:publish-config
   php artisan mediaman:publish-migration
   

3. Link Storage:

bash
   php artisan storage:link
   

4. Run Migrations:

bash
   php artisan migrate
   

5. Use MediaMan in Your Livewire Components:

php
   // In your Livewire component
   use Illuminate\Database\Eloquent\Model;
   use FarhanShares\MediaMan\Traits\HasMedia;

   class MyComponent extends Component {
       use HasMedia;

       public function mount() {
           // Initialize media
       }

       public function uploadMedia() {
           // Upload media
       }

       public function attachMedia() {
           // Attach media to a model
       }
   }
   

Integrating MediaMan with Inertia.js

1. Install MediaMan:

bash
   composer require farhanshares/laravel-mediaman
   

2. Publish Configuration Files:

bash
   php artisan mediaman:publish-config
   php artisan mediaman:publish-migration
   

3. Link Storage:

bash
   php artisan storage:link
   

4. Run Migrations:

bash
   php artisan migrate
   

5. Use MediaMan in Your Inertia Components:

php
   // In your Inertia component
   use Illuminate\Database\Eloquent\Model;
   use FarhanShares\MediaMan\Traits\HasMedia;

   class MyComponent extends Component {
       use HasMedia;

       public function mount() {
           // Initialize media
       }

       public function uploadMedia() {
           // Upload media
       }

       public function attachMedia() {
           // Attach media to a model
       }
   }
   

By following these steps, you can integrate MediaMan with both Livewire and Inertia.js, allowing you to manage media effectively in your Laravel application.

Citations:
[1] https://laracasts.com/discuss/channels/livewire/can-you-use-inertia-and-livewire-at-the-same-time
[2] https://www.reddit.com/r/laravel/comments/s9za3a/what_are_your_honest_thoughts_about_livewire_vs/
[3] https://laravel-news.com/livewire-inertia
[4] https://github.com/FarhanShares/laravel-mediaman
[5] https://laracasts.com/discuss/channels/inertia/inertiajs-vs-livewire-laravel