mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-21 05:14:14 +00:00
Merge branch 'too/marking' into 'master'
Too/marking See merge request CIEFWorldwideSdnBhd/exchange!22
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Marking;
|
||||
|
||||
class MarkingController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return Marking::all();
|
||||
}
|
||||
|
||||
public function show(Marking $marking)
|
||||
{
|
||||
return $marking;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$marking = Marking::create($request->all());
|
||||
|
||||
return response()->json($marking, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Marking $marking)
|
||||
{
|
||||
$marking->update($request->all());
|
||||
|
||||
return response()->json($marking, 200);
|
||||
}
|
||||
|
||||
public function delete(Marking $marking)
|
||||
{
|
||||
$marking->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Marking extends Model
|
||||
{
|
||||
protected $fillable = ['email','marking'];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateMarkingTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('markings', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('email')->unique();
|
||||
$table->string('marking')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('marking');
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -81,8 +81,13 @@ Route::group(['middleware' => 'role:admin'], function() {
|
||||
Route::post('setting-beneficiary', 'SettingBeneficiaryController@store');
|
||||
Route::put('setting-beneficiary/{beneficiary}', 'SettingBeneficiaryController@update');
|
||||
Route::delete('setting-beneficiary/{beneficiary}', 'SettingBeneficiaryController@delete');
|
||||
});
|
||||
|
||||
Route::get('marking', 'MarkingController@index');
|
||||
Route::post('marking', 'MarkingController@store');
|
||||
Route::get('marking/{beneficiary}', 'MarkingController@show');
|
||||
Route::put('marking/{beneficiary}', 'MarkingController@update');
|
||||
Route::delete('marking/{beneficiary}', 'MarkingController@delete');
|
||||
});
|
||||
|
||||
Route::get('update-rate', 'RateController@index');
|
||||
Route::get('update-rate/{rate}', 'RateController@show');
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\User;
|
||||
use App\Role;
|
||||
use Artisan;
|
||||
|
||||
class MarkingTest extends TestCase
|
||||
{
|
||||
protected $user;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Artisan::call('db:seed');
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user->attachRole(Role::Where('name','admin')->first());
|
||||
}
|
||||
|
||||
public function testStore(){
|
||||
$response =
|
||||
$this->actingAs($this->user)
|
||||
->postJson('/api/marking/',[
|
||||
'email' => 'user@example.com',
|
||||
'marking' => 'markingcode123'
|
||||
])
|
||||
->assertStatus(201);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user