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?
For example, if your view is stored at resources/views/admin/profile.blade.php , you may return it from one of your application's routes / controllers like so: return view('admin.profile', $data);
Views in Laravel are created in the resources/views folder. You can change base path for views by editing config/view. php file and changing `realpath(base_path('resources/views'))` to the new location for the views.
@include is just like a basic PHP include, it includes a "partial" view into your view. @extends lets you "extend" a template, which defines its own sections etc. A template that you can extend will define its own sections using @yield , which you can then put your own stuff into in your view file.
View Composers are callback or a class method that gets executed when a view is rendered. That means when Laravel loads a *. blade. php file to serve to the browser to display contents it executes View Composers.
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
Just to add one more thing, you can choose which type of resources to publish by using the tags for the publish command
php artisan vendor:publish --provider="Kordy\Ticketit\TicketitServiceProvider" --tag="views"
Publish only ticketit views (destination: base_path/resources/views/vendor/ticketit
)
If for any reason, found extending views is not enough and want to extend functionalities or controllers themselves, ticketit allows using of custom routes file, you can use that to point to your own custom controllers.
Other supported vendor publish tags:
php artisan vendor:publish --provider="Kordy\Ticketit\TicketitServiceProvider" --tag="lang"
Publish only ticketit translation files (destination: base_path/resources/lang/vendor/ticketit
)
php artisan vendor:publish --provider="Kordy\Ticketit\TicketitServiceProvider" --tag="db"
Publish only ticketit migration files (destination: base_path/database/migrations
)
php artisan vendor:publish --provider="Kordy\Ticketit\TicketitServiceProvider" --tag="public"
Publish only ticketit web resources (js, css, ..) files (destination: public_path/vendor/ticketit
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With