first of all u have to describe how to connect tables;
in your Market model
public function Calendar ()
{
return $this->hasOne( 'App\Calendar' ); //or hasMany ( up to you, its about application how to work logic )
}
after, you can call market item with calendar or calendars
$markets = App\Market::with('Calendar')->get();
Add this method in your Calendar modal
public function isOpen() {
if ( $this->event == 'open') return true;
return false;
}
public function isClose() {
if ( $this->event == 'close') return true;
return false;
}
public function isPromo() {
if ( $this->event == 'promo') return true;
return false;
}
its ready to use in your blade;
<table>
@foreach ( $markets as $item)
<tr>
<td>{{ item->name }}</td>
<td>{{ item->Calendar->isOpen() ? 'Opened' : 'Closed or Promoted' }}</td>
</tr>
@endforeach
</table>
Ah, so I don't have to use some package like this one: https://github.com/maddhatter/laravel-fullcalendar ??
There is no package used in my code. Its modals and laravel eloquent magic
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community