mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-22 05:54:18 +00:00
fixed the issues that were pointed out except the pdf test
This commit is contained in:
@@ -4,7 +4,6 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Company;
|
||||
//use Image; //only used in companyProfile(), uncomment if using that portion of the code
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Validator;
|
||||
|
||||
@@ -14,7 +13,8 @@ class CompanyController extends Controller
|
||||
{
|
||||
$input = $request->all();
|
||||
Company::create($input);
|
||||
return redirect('/');
|
||||
return response()->json(['input'=>$input],201);
|
||||
//return redirect('/');
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
@@ -46,7 +46,7 @@ class CompanyController extends Controller
|
||||
$company = Company::find($id);//find the company first
|
||||
if (!$company)
|
||||
{
|
||||
return response()->json(['message'=>'Document not found'],200);
|
||||
return response()->json(['message'=>'company for company_prof not found'],200);
|
||||
}
|
||||
//validaating file types
|
||||
$validator = Validator::make($request->all(), [
|
||||
@@ -54,7 +54,7 @@ class CompanyController extends Controller
|
||||
]);
|
||||
if($validator->fails())
|
||||
{
|
||||
return "failed";
|
||||
return response()->json(['message'=>'Incorrect format'],200);
|
||||
}
|
||||
|
||||
if($file = $request->file('company_profile')) //company profile picture
|
||||
@@ -70,16 +70,6 @@ class CompanyController extends Controller
|
||||
'company_profile',/*folder name*/ $file, $unique_name. '.' .$ext
|
||||
);
|
||||
$company->company_profile = $unique_name. '.' .$ext; //update database
|
||||
// only use the following section of the code if you're omiting the upper portion, also uncomment the Image Library on line 7 & install Intervention Image package
|
||||
/*
|
||||
$name = $file->getClientOriginalName();
|
||||
$img_file = $request->file('company_profile');
|
||||
Image::make($img_file)->resize(300,300)->save(public_path('\company_profile'));
|
||||
//return $img_file;
|
||||
// $file->move('uploads/company_profile/', $img_file);
|
||||
|
||||
$input['company_profile'] = $name;
|
||||
*/
|
||||
} //end if
|
||||
$company->save();
|
||||
return response()->json(['company'=>$company],200);
|
||||
@@ -90,7 +80,7 @@ class CompanyController extends Controller
|
||||
$company = Company::find($id); //find the company first
|
||||
if (!$company)
|
||||
{
|
||||
return response()->json(['message'=>'Document not found'],200);
|
||||
return response()->json(['message'=>'company for reg_cert not found'],200);
|
||||
}
|
||||
|
||||
//validating file types
|
||||
@@ -98,7 +88,7 @@ class CompanyController extends Controller
|
||||
'reg_cert' => 'mimes:jpg,jpeg,bmp,png,gif,svg,pdf'
|
||||
]);
|
||||
if($validator->fails()){
|
||||
return "failed";
|
||||
return response()->json(['message'=>'Incorrect format'],200);
|
||||
}
|
||||
|
||||
if($request->hasFile('reg_cert')) //Registration Certificate upload
|
||||
|
||||
+2
-4
@@ -160,8 +160,7 @@ return [
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
Intervention\Image\ImageServiceProvider::class
|
||||
App\Providers\RouteServiceProvider::class
|
||||
],
|
||||
|
||||
/*
|
||||
@@ -214,8 +213,7 @@ return [
|
||||
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
|
||||
'Twilio' => Aloha\Twilio\Support\Laravel\Facade::class,
|
||||
'Laratrust' => Laratrust\LaratrustFacade::class,
|
||||
'auth.password.broker' => Illuminate\Auth\Passwords\TokenRepositoryInterface::class,
|
||||
'Image' => Intervention\Image\Facades\Image::class
|
||||
'auth.password.broker' => Illuminate\Auth\Passwords\TokenRepositoryInterface::class
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -35,13 +35,12 @@ class CompanyTest extends TestCase
|
||||
'country'=>'testing',
|
||||
'contact_person'=>'testing',
|
||||
]);
|
||||
var_dump($response);
|
||||
$response->assertStatus(302); //here 302 as the page redirects
|
||||
$response->assertStatus(201);
|
||||
}
|
||||
|
||||
public function testPUT()
|
||||
{
|
||||
$response = $this->json('PUT', '/api/company/9', [
|
||||
$response = $this->json('PUT', '/api/company/2', [
|
||||
'company_name'=>'changed testing',
|
||||
'registration_no'=>'testing',
|
||||
'tax_no'=>'testing',
|
||||
@@ -61,7 +60,7 @@ class CompanyTest extends TestCase
|
||||
{
|
||||
Storage::fake('company_profile');
|
||||
|
||||
$response = $this->json('POST', '/api/company/company_profile/9', [
|
||||
$response = $this->json('POST', '/api/company/company_profile/2', [
|
||||
'company_profile' => UploadedFile::fake()->image('comp.jpg')
|
||||
]);
|
||||
dd($response->getContent());
|
||||
@@ -72,8 +71,8 @@ class CompanyTest extends TestCase
|
||||
{
|
||||
Storage::fake('reg_cert');
|
||||
|
||||
$response = $this->json('POST', '/api/company/reg_cert/9', [
|
||||
'reg_cert' => UploadedFile::fake()->image('reg.pdf')
|
||||
$response = $this->json('POST', '/api/company/reg_cert/2', [
|
||||
'reg_cert' => UploadedFile::fake()->create('document.pdf')//, $sizeInKilobytes)
|
||||
]);
|
||||
dd($response->getContent());
|
||||
$response->assertStatus(200);
|
||||
|
||||
Reference in New Issue
Block a user