Browse Source

product transaction

pull/1/head
wahyun 9 months ago
parent
commit
90e51a829d
  1. 30
      app/Http/Controllers/ProductTransactionController.php
  2. 25
      app/Models/ProductTransaction.php
  3. 1
      routes/web.php

30
app/Http/Controllers/ProductTransactionController.php

@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProductTransaction;
class ProductTransactionController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'company_id' => 'required|integer',
'type_paket' => 'required|string',
'amount' => 'required',
'exp_ospro' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = ProductTransaction::create($data);
if ($result) {
return response()->json(['status' => 'success','data' => $result, 'message' => 'Add Transaction successfully!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Add data Transaction failed!', 'code' => 400], 400);
}
}
}

25
app/Models/ProductTransaction.php

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProductTransaction extends Model
{
protected $table = 't_transaction';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'company_id',
'type_paket',
'amount',
'exp_ospro',
'pay_date',
'created_at',
'updated_at',
'created_by',
'updated_by'
];
}

1
routes/web.php

@ -9,6 +9,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
// Landing Route
$router->post('/send-email', 'AuthController@sendEmail');
$router->post('/company-management-user/add', 'CompanyController@add');
$router->post('/product-transaction/add','ProductTransactionController@add');
$router->post('/company-management-user/search', 'CompanyController@search');
$router->post('/human-resource-user/add', 'HumanResourceController@add_user');
$router->get('/company-management-user/edit/{id}', 'CompanyController@edit');

Loading…
Cancel
Save