Good day!
Please tell me how to make a selection from the link table for the current date? For example, there is a table of managers in which the name, department, and general plan are indicated. And there is a sales table, in which there are fields the name, amount, and choice of the manager. Each manager can make multiple sales.
I need to receive in the controller those sales that are not shown on the current date, for the last month.
I now get the data like this:
$managers = Manager::with('sales')->get(); And in the view I display it like this:
@forelse ( $managers as $manager ) <tr> <td>{{ $manager->name }}</td> <td>{{ $manager->department }}</td> <td>{{ $manager->overall_plan }}</td> <td>{{ $manager->sales->sum('summa') }}</td> <td> <progress class="progress is-success" id="progress" min="0" max="100" value="{{$manager->sales->sum('summa') / $manager->overall_plan * 100}}"> </progress> <span class="percent">{{ round( $manager->sales->sum('summa') / $manager->overall_plan * 100 ) }} %</span> </td> </tr> @empty <h3>Нет данных</h3> @endforelse It would be desirable that only sales of the current month would be displayed and the past ones would not be displayed.
The fact is that one manager can have several sales, how can I make such a request so that I can take data only on the current date? Or what other way is more correct?
The managers table has a hasMany relationship with sales, and sales has an inverse belongsTo relationship with the Manager.
Here is the managers page
Here is a form for adding a manager 
In the form of adding a sale manager is selected from the table manager.




$managers = Manager::with('sales')->get();I have a collection of managers here, and every manager in the collection has a relations field, and in it there is a collection of the Sale model. Some managers have several sales. Correspondingly, in the collection of managers, there is a collection with several sales. Do I need to run through them foreach and do a logical check on the field created_at for each sale in a cycle? I can't figure out how to do it here - Dolphin