Reputation: 2893
In one of my CRUDs show page, I have a simple button
<td> {!! link_to_route('', 'Generate PDF', array($project->id), array('class' => 'btn btn-info')) !!}</td>
Ignore the link to route for now, that will probably change. Anyway, when they click the button, I want to take the information from that CRUD and generate a PDF from it.
So I am going to be using TCPDF. Initially, I want to create a base class and set out some standards for the PDF. To do this, I will extend TCPDF
abstract class Document extends \TCPDF
So when I create this class, where should it be placed within my Laravel structure? Should it be in the HTTP folder, Providers etc. Where do generic classes like this generally get placed?
Secondly, how far do I need to go for this button? By this I mean I will probably have to create a route for it, and then have something implement the Document class. Is there a need for a Model?
So far, a lot of what I have done has been very CRUD based, so its all in the MVC structure. But for a simple button which generates a PDF, I was just wondering what the best practice was.
Upvotes: 0
Views: 82
Reputation: 15760
What I usually do for code like this is create a directory like app/Libraries
. Then I place my class inside that directory with a namespace of App\Libraries
.
To use the library, reference it like this: $lib = new \App\Libraries\MyClass();
Upvotes: 1