Laravel / JQGrid – Order by on laravel dynamic property

I’m currently working with free JQGrid 4.6 version and Laravel 5.8 and I have some issue with a grid that I have develop. So here is the problem recap : i want to sort some columns that contains datas coming from dynamic attributes of my model Contact.

Here is the columns of the grid :

{name: "ID_PROJET", hidden:true},
{name: "DT_REEL_DON", align:'center',formatter:'date',sorttype : 'date', datefmt: 'd/m/Y',formatoptions: {srcformat:'Y-m-d',newformat: "d/m/Y"},excel:true, width:90},
{name:"LIBELLE_PROJ", excel:true,width:250},
{name:"contact.full_identite", excel:true},
{name:"MT_DON",formatter:'currency',align:'right',sorttype:'numeric',excel:true, width:60},
{name:"lib_type_don",excel:true, sortable:false},
{name:"MAIL", excel:true},
{name:"ADRESSE1", excel:true},
{name:"CDPOST", excel:true,width:50},
{name:"COMMUNE", excel:true},
{name:"PAYS", excel:true,width:70},
{name: "action",template:"action",sortable:false, width: 75, align:"center",excel:false}

Datas come from this request that i serialize to JSON :

$dons = $dons->with(['projet','contact'])

$sidx, $sord, $start and $limit are GET parameters send by JQGrid when the user have done an action on the grid (paging, sorting etc)

It’s working great, but the problem is for the column contact.full_identite which is not a field into my contacts table. It’s a laravel dynamic attributes define like that :

    public function getFullIdentiteAttribute() {
// si entreprise
if ($this->TYPE_CONTACT_ == 1) {
return $this->ORGANISME;
// si particulier
else if ($this->TYPE_CONTACT_ == 2) {
return $this->NOM . ' ' . $this->PRENOM;

The idea is to return the full name of a person if this is a particular or the organisation name if this a company. So i’m searching for a way to apply an orderBy clause (in my request above) on this dynamic attribute when the user want to sort this column. For the moment, i sort on the field NOM and it’s working good but this is not the result that i expect.

Here is a screenshot of a structure part of my contact table :

Structure table

Thanks in advance for your help, if i wasn’t enough clear don’t hesitate to ask me some details

from Newest questions tagged laravel-5 – Stack Overflow

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.