add bookingcontroller@report, still in testing

This commit is contained in:
Too
2018-06-28 20:52:47 +08:00
parent e36c2a52af
commit cabf43cfdc
3 changed files with 25 additions and 10 deletions
+10 -9
View File
@@ -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('<html><body><h1>Welcome to PhantomMagick</h1></body></html>')
->save('/storage/app/report/multipage.pdf');
}
}
}
+1
View File
@@ -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');
});
+14 -1
View File
@@ -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());
}
}