pos-gis/app/Models/taxModel.php

69 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2024-10-07 06:13:42 +00:00
<?php
namespace App\Models;
use Datatables, DB;
use Exception;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Yajra\DataTables\DataTables as DT;
use Illuminate\Support\Facades\Http;
use Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\User as Authenticatable;
class taxModel extends Model
{
protected $primaryKey = 'tax_id';
protected $table = 'reff_tax';
public $timestamps = false;
public function initData($request,$route)
{
// INIT DB
$data['title'] = 'Tax';
$data['actButton'] = ['edit'];
$data['tableHead'] =
array(
["Tax Name","all","tax_nm"],
["Percentage","all","tax_prs"],
["Act","all","action"]
);
$cGlobal = new Controller();
$data['db'] = $this->table;
$data['db_key'] = $this->primaryKey;
$data['route'] = $route;
$dtable = \DB::select("SELECT * from reff_tax order by tax_id desc");
// LIST DATA TABLE
$data['data_table'] = $dtable;
// FORM FIELD FOR STORE
$data['set_field'] = [
'tax_nm' => $cGlobal->cleanString($request->post('tax_nm')),
'tax_prs' => $request->post('tax_prs')
];
// GET DATA FOR EDIT
if ($request->post('id')) {
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM reff_tax where tax_id = ?",[$request->post('id')]))->first();
}
foreach($data['tableHead'] as $v){
$arrHead[] = $v[2];
}
$data['head'] = implode(",",$arrHead);
return $data;
}
public function getDT($data,$init)
{
$dt = DT::of($data);
return $dt;
}
}