I have a "booking" that has relationships with the "markets" and "stalls"
I have the Selects working on the create form but the index blade is not displaying correctly.
It should take the "id" and convert it to the "name" field as in the below
<td>{{$user->role ? $user->role->name : 'User has no role'}}</td>
And this displays correctly with the following Model code: public function role(){
return $this->belongsTo('App\Role');
}
and this is my "Bookings" Model:
public function marketdate(){
return $this->belongsTo('App\Markets');
}
public function stallstype() {
return $this->belongsTo('App\Stalls');
}
With the following on the index.blade:
...
<td>{{$booking->marketdate ? $booking->marketdate->date : '-' }}</td>
<td>{{$booking->stallstype ? $booking->stallstype->name : '-'}}</td>
...
But this just shows the "-" when it renders the page
the ID's that are stored in the database are correct and do correlate it is just not displaying correctly.
One other thing, the table schemas are as follows:
Stalls table:
Schema::create('stalls', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->integer('cost');
$table->timestamps();
});
Markets table:
Schema::create('markets', function (Blueprint $table) {
$table->increments('id');
$table->string('date');
$table->integer('is_active');
$table->timestamps();
});
The error is:
at PhpEngine- >evaluatePath('C:\xampp\htdocs\moowoos\storage\framework\views/3bcb71b43fffee7f9 a9edf18bfb397ab94380507.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'bookings' => object(Collection), 'markets' => array('Saturday 4th March', 'Saturday 5th April', 'Saturday 6th May', 'Saturday 7th June', 'Saturday 8th July', 'Saturday 8th July'), 'stalltype' => array('Preloved', 'Craft', 'Business'))) in compiled.php line 15361
at CompilerEngine->get('C:\xampp\htdocs\moowoosesources\views/admin/bookings/index.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'bookings' => object(Collection), 'markets' => array('Saturday 4th March', 'Saturday 5th April', 'Saturday 6th May', 'Saturday 7th June', 'Saturday 8th July', 'Saturday 8th July'), 'stalltype' => array('Preloved', 'Craft', 'Business'))) in compiled.php line 15193
Which shows that it is returning the array