'laravel Eloquent JavaScript php
how can i throw a record to the datatable
I use a eloquent one-to-one relationship. I try several code for it. i need to fetch the status_xtitle to the datatable but it has an error.
this is the Controller
public function get_user_info()
{
$dir = UserBasic::All();
$datatables = Datatables::of($dir)
->setRowId(function($data){
return $data->user_id;
});
$rawColumns = ['user_xusern','user_xfirstname','user_xmiddlename','user_xlastname','user_xbirthdate', 'user_xtitle'];
return $datatables->rawColumns($rawColumns)->make(true);
}
and this the javascript in html
<script type="text/javascript">
$(document).ready(function()
{
loadDatatable();
});
function loadDatatable()
{
@php
$columns = array ([ 'data' => 'user_id'],
['data' => 'user_xusern'],
['data' => 'user_xfirstname'],
['data' => 'user_xmiddlename'],
['data' => 'user_xlastname'],
['data' => 'user_xbirthdate'],
['data' => 'user_status']);
@endphp
var url = "{!!route('dir.user')!!}";
load_datables('#table4',url,{!! json_encode($columns)!!},null);
}
models
class Directorystatus extends Model
{
use HasFactory;
protected $table = 'user_status';
protected $fillable = ['status_id' , 'status_xtitle'];
public function userbasic() {
return $this->belongsto(UserBasic::class,'status_xuser','user_id');
}
}
class UserBasic extends Model
{
use HasFactory;
protected $table = 'user_basic';
protected $primaryKey = 'user_id';
public function user_emp() {
return $this->belongsTo(UserEmployment::class,'user_xusern','emp_xuser');
}
public function user_status() {
return $this->belongsTo(Directorystatus::class,'user_xusern','user_xtitle');
}
}
Solution 1:[1]
If you're using Three.js version r125 or later, you should be able to get the position attribute of any geometry with the .getAttribute() method.:
const cylinderGeometry = new THREE.CylinderGeometry( 5, 5, 5, 5, 15, 5, 30 );
const posAttribute = cylinderGeometry.getAttribute("position");
const posArray = posAttribute.array;
If you're using version r124 or earlier, then the Geometry generated used to be structured differently. This approach is now deprecated, so it's recommended you update to a newer version.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Marquizzo |
