mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 12:34:06 +00:00
contact controller model table
This commit is contained in:
@@ -32,6 +32,15 @@ class ContactController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
public function searchContact($id)
|
||||
{
|
||||
|
||||
|
||||
|
||||
$matchedTerm = Breed::where('ff_id', 'LIKE', $id . '%')->get();
|
||||
return response()->json($matchedTerm);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
@@ -42,7 +51,7 @@ class ContactController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$contact = Contact::create($request->all());
|
||||
|
||||
// $contact->created=true;
|
||||
return response()->json($contact, 201);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class CreateContactsTable extends Migration
|
||||
{
|
||||
Schema::create('contacts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ff_id');
|
||||
$table->integer('ff_id')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
+2
-1
@@ -36,4 +36,5 @@ Route :: get('/warehouse','WarehouseController@index');
|
||||
|
||||
Route :: delete('/contacts/{ff_id}','ContactController@destroy');
|
||||
Route :: get('/contacts','ContactController@index');
|
||||
Route :: post('/contacts','ContactController@store');
|
||||
Route :: post('/contacts','ContactController@store');
|
||||
Route::get('/company/search/{name}', 'CompanyController@searchContact');
|
||||
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
namespace Tests\Unit\contactTest;
|
||||
namespace Tests\API;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
|
||||
class contactTest extends TestCase
|
||||
{
|
||||
@@ -15,13 +17,18 @@ class contactTest extends TestCase
|
||||
*/
|
||||
public function testBasicExample()
|
||||
{
|
||||
$response = $this->json('POST', '/api/contacts', ['ff_id' => '10']);
|
||||
$response = $this->json('POST', '/api/contacts', ['ff_id' => '14']);
|
||||
|
||||
$response
|
||||
->assertStatus(201);
|
||||
// ->assertExactJson([
|
||||
// 'created' => true,
|
||||
// ]);
|
||||
// ->assertJson(
|
||||
// [
|
||||
// 'success' => true,
|
||||
// 'message' => 'Success'
|
||||
// //'response' => [
|
||||
// // 'id' => $contacts->ff_id,
|
||||
// // ]
|
||||
// ]);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +46,75 @@ class contactTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
// public function testUPdate()
|
||||
// {
|
||||
//
|
||||
// $response = $this->json('PUT', '/api/warehouse/{war_id}' . $article->id, $payload, $headers)
|
||||
// ->assertStatus(200)
|
||||
// ->assertJson([
|
||||
// 'id' => 1,
|
||||
// 'title' => 'Lorem',
|
||||
// 'body' => 'Ipsum'
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// public function testPostWarehouse()
|
||||
// {
|
||||
// $response = $this->json('POST', '/api/warehouse', [
|
||||
//
|
||||
// 'address'=> '2d',
|
||||
// 'city'=>'cj ',
|
||||
// 'zip'=>' 123',
|
||||
// 'state' =>' sl',
|
||||
// 'contact_person' =>'asif ',
|
||||
// 'contact_person_no' =>'1212122 ',
|
||||
// 'branch'=>'yap ',
|
||||
// 'country' =>' ba',
|
||||
// 'company_id' =>'1212 '
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ]);
|
||||
//
|
||||
// $response
|
||||
// ->assertStatus(201);
|
||||
//// ->assertJson([
|
||||
//// 'created' => true,
|
||||
// // ]
|
||||
// //);
|
||||
// }
|
||||
|
||||
public function testPutWarehouse()
|
||||
{
|
||||
$response = $this->json('PUT', '/api/warehouse/6', [
|
||||
|
||||
'address'=> '2g',
|
||||
'city'=>'cj ',
|
||||
'zip'=>' 123',
|
||||
'state' =>' sl',
|
||||
'contact_person' =>'tuytguy',
|
||||
'contact_person_no' =>'1212122 ',
|
||||
'branch'=>'yap ',
|
||||
'country' =>' ba',
|
||||
'company_id' =>'1212 '
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]);
|
||||
|
||||
$response
|
||||
->assertStatus(200);
|
||||
// ->assertJson([
|
||||
//
|
||||
// ]
|
||||
// );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user