Hello guys I want to have values from a different table but same database and print them on a dropdown, av tried several ways and here but i get this error
Call to undefined method Illuminate\Auth\SessionGuard::myVehicles() (View: /home/vagrant/www/martin/resources/views/templates/applications.blade.php)
I want to get them from a table containing all vehicles and print all the vehicles so that the user can select one of the vehicles in the database... here is vehicle model
<?php
namespace Martin\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Vehicle extends Authenticatable
{
use Notifiable;
//
use Notifiable;
protected $guard="vehicle";
protected $table="vehicles";
protected $fillable=[
'id',
'vehicle_registration_number',
'vehicle_type',
'vehicle_size',
];
public function user(){
return $this->belongsTo('Martin\Models\User');
}
public function myVehicles(){
$vehicles = Martin\Models\Vehicle::all();
foreach ($vehicles as $vehicle) {
echo $vehicle->vehicle_registration_number."-".$vehicle->vehicle_type."-".$vehicle->vehicle_size.' seaters <br/>';
}
}
}
and the following is the dropdown i want to display my data in the applications.blade.php so that a user can select one of the vehicles...
<select name="vehicle_registration_number" class="form-control">
</select>
and also I may ask what name do you assign to the select box do you assign it the same name as the original name of the input i.e text area of the original one? kindly reply... if any more clarification is needed am ready... Thankyou!
via Martin Gacheru