I have an Invoice controller it looks something like this
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;
use App\Event;
use App\Employee;
use App\Invoice;
use Mail;
use View;
class ViewinvoiceController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function getIndex($order_id)
{
$id=$order_id;
$invoicedata=Invoice::where('Id',$id)->get();
$html22 = View('viewinvoice')->with(array('invoicedata'=>$invoicedata ))->render();
require_once(app_path().'/libs/html2pdf/html2pdf.class.php');
$html2pdf = new \HTML2PDF('P','A4','en',true,'UTF-8',array(0, 0, 0, 0));
// $html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->WriteHTML($html22);
$html2pdf->Output('Invoice.pdf');
}
}
I want to use this controller in other controller which looks like this
class CollectionController extends Controller
{
public function __construct(){
$this->middleware('role:collector'); // replace 'collector' with whatever role you need.
}
public function getInvoice($order_id){
//Here I have to write the logic of getting the invoice from the invoiceController
}
}
I googled and found out one way is to write a service to get invoice ,
I can make it as a normal class as service but I don't know whats the right way in laravel 5
Any suggestion
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NuGmYl
via IFTTT
Aucun commentaire:
Enregistrer un commentaire