[Vuejs]-How to get data from database using id?

4👍

Use print_r() method to prints array

class Zones extends Model {
protected $primaryKey = 'zone_id';
public function getZone($id){
     $zone = Zones::where('zone_id','=',$id)->first();

     print_r($zone);
     exit(0);
   }
}

1👍

printf($var) 

it prints normal variable string , integer etc

print_r($var);

it prints array

$zone is an array so you need to use print_r

👤bimal

0👍

You could use dd($your_data) function instead of print_r() and exit(0).

There is also dump($your_data) which just prints but not dies.

Also you could use (‘zone_id’,$id) instead of (‘zone_id’,’=’,$id).

Leave a comment