laravellaravel-bladevendor

How do you extend a view from a package in Laravel?


So i integrated this package to my application, https://github.com/thekordy/ticketit and this package has its own view and i want to modify the views like the create.blade.php,.. how would i do this appropriately?

because my current solutions is just to copy the view from the package change the return view('create'); in my controller?


Solution

  • You will notice many packages include in its instalation proccess this command:

    php artisan vendor:publish
    

    What it does behind the scenes is it looks for all package's service providers instructions in order to figure out it anything should be "published" (meaning copying from vendor folder to config/, views/ etc)

    I looked at your package's service provider: https://github.com/thekordy/ticketit/blob/0.2/src/TicketitServiceProvider.php and from line 179 to 182, the package seems to have the correct "publish" instructions.

    Which means probably that the documentation skiped this part.

    So, you should just basically hit the command php artisan vendor:publish and it will copy views, translations, public and migrations folder to your own apps folders.

    Then you will see inside your resources/views a vendor folder, which will now have the ticketit views inside it.

    Laravel figure it out when you say "view('ticketit.form.index')" and it will first look inside your own resources folder, if it don't find the content, it will try to look inside the package's folder.

    For more, read the docs:https://laravel.com/docs/5.4/packages#views