From cabf43cfdcb7b2a4871566ed2df6fa9c7efa4c44 Mon Sep 17 00:00:00 2001 From: Too Date: Thu, 28 Jun 2018 20:52:47 +0800 Subject: [PATCH] add bookingcontroller@report, still in testing --- app/Http/Controllers/BookingController.php | 19 ++++++++++--------- routes/api.php | 1 + tests/Feature/BookingTest.php | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 8df3c574..4ed0b0b8 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -11,6 +11,7 @@ use App\UserBankSlip; use App\User; use App\Invoice; use App\SettingCredit; +use Anam\PhantomMagick\Converter; use Auth; use Validator; use DateTime; @@ -635,13 +636,13 @@ class BookingController extends Controller return response()->json(['message'=>"Success"],200); } - public function report(Request $request){ - $conv = new \Anam\PhantomMagick\Converter(); - $conv->source('http://google.com') - ->toPng() - ->save('/your/destination//google.png'); - $conv->toPng(); - - } + public function report(Request $request, $id) + { + $conv = new Converter(); + // $conv->setBinary('/vendor/anam/phantomjs-linux-x86-binary/bin/phantomjs'); + $conv->addPage('

Welcome to PhantomMagick

') + ->save('/storage/app/report/multipage.pdf'); -} + + } +} \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 18bda2dd..671c973b 100644 --- a/routes/api.php +++ b/routes/api.php @@ -105,6 +105,7 @@ Route::group(['middleware' => ['role:admin']], function() { Route::patch('/booking/{id}/update-china-bankslip','ChinaBankSlipController@update'); Route::get('/booking/{id}/po', 'BookingController@showPurchaseOrder'); + Route::post('/booking/{id}/supplier-booking-report','BookingController@report'); }); diff --git a/tests/Feature/BookingTest.php b/tests/Feature/BookingTest.php index 9dbc1b68..be54ab30 100644 --- a/tests/Feature/BookingTest.php +++ b/tests/Feature/BookingTest.php @@ -156,7 +156,7 @@ class BookingTest extends TestCase ->assertSuccessful(); } - // Only this is Admin permision required + // Admin permision required public function testUploadInvoice(){ $this->user->roles()->sync([]); $this->user->attachRole(Role::Where('name','admin')->first()); @@ -179,4 +179,17 @@ class BookingTest extends TestCase $response->assertSuccessful(); } } + + // Admin permision required + public function testReport(){ + $this->user->roles()->sync([]); + $this->user->attachRole(Role::Where('name','admin')->first()); + + $response = + $this->actingAs($this->user) + ->json('POST', '/api/booking/' . $this->booking->id . '/supplier-booking-report', [ + 'amount' => '12345' + ]); + dd($response->getContent()); + } }