wahyun
11 months ago
3 changed files with 56 additions and 0 deletions
@ -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); |
||||
} |
||||
} |
||||
} |
@ -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' |
||||
]; |
||||
} |
Loading…
Reference in new issue