dimanche 10 septembre 2017

laravel - controller return diferent array

I need return array, but, when send a id with two or more results, the return array is this

enter image description here

But I need, return's in this format

enter image description here

My code is this

<?php

namespace RocOnline\Http\Controllers;

use Illuminate\Http\Request;
use RocOnline\Equipment;

class EquipmentController extends Controller
{
private $modelEquipment;
private $allListActive;

public function __construct(Equipment $equipment)
{
    $this->middleware('auth');
    $this->modelEquipment = $equipment;
    $this->allListActive = $this->modelEquipment->all();

}

public function listAll()
{
    return $this->allListActive;
}

public function byClientId($id){
    return $this->allListActive->where('idclient', $id)->toArray();
}
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire