mardi 17 septembre 2019

Laravel nested select and conditional statement in view blade

So I've succeded to make a calendar display for the current month. This time I want to show one event detail for a specific date. I'm not sure how to get the $event data where $event = $date.

This is the controller. I have event and dates to be use in view.


    $event = Event::where("started_at", '>=', Carbon::now()->subDays(30)->toDateTimeString())
                ->orderBy("started_at", "asc")
                ->first();
            $data["event"] = $event;
            $data["month"] = Carbon::now()->month;
            $data["dates"] = range('1', date('t'));

            return view('event.all', $data);


This is the event.all view


@foreach($dates as $date)
                    <div class="seven-cols">
                        <div class="titlehead">
                            <h6></h6><h6 style="color: lightgrey;"></h6>
                            <div style=" "></div>
                            @if($event->started_at == $date)
                                <div>Test</div>
                            @endif
                        </div>
                    </div>
                @endforeach


What I got for this code

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire