jeudi 10 novembre 2016

How do I get a assign a record value to a variable in Laravel 5.3?

I need to display all the vehicle records belonging to properties of the currenty logged on user. Before I pass the data to the view I need to filter out all the properties except those owned by the current user id.

I have a relationship in the Vehicle model that performs the foreign key constraint.

public function propiedad(){
    return $this->belongsTo('App\Property', 'propiedad_id','id' );
}

My Controller is using this filter before passing the data to the view. I assume I have to acquire the property ids that belong to the user before I filter the vehicles that belong to those properties. This is where I am having trouble.

    $user_properties = array(?????);
    $Vehiculo = Vehiculo::where('propiedad_id', $user_properties);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire