Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alikalan's avatar

Awarding prizes to pilots for each flight date in Laravel

I have tree model : Pilot , Flight , Prize

Flight model contains : pilot_id , flight_id , flight_date, prize_check=(defalt = 0)

Prize model contains : pilot_id, flight_id, flight_date, prize_count

I want to give pilots a prize once a day. Even if they fly twice on the repetitive date, they will be awarded a prize.

Exceptions : If the pilots' flight dates are weekends, they will be awarded two prizes.

I want to check Flight model daily by Task Scheduling and save Prize model . and Update prize_check==1 after check completed

example :

-----------------------------------------------------------------------------
pilot_id ---- flight_id ---- flight_date ---- is_weekend 	--- prize_count 
	1	 ---- 	2		----  2020-04-01 ----	true		---   	2
	1	 ---- 	3		----  2020-04-01 ----	true		---   	0
	1	 ---- 	4		----  2020-04-02 ----	false		---   	1
	1	 ---- 	5		----  2020-04-02 ----	false		---   	0
	1	 ---- 	6		----  2020-04-03 ----	false		---   	1
	1	 ---- 	7		----  2020-04-03 ----	false		---   	0
	1	 ---- 	8		----  2020-04-03 ----	false		---   	0
----------------------------------------------------------------------------	

How can I write this?

0 likes
0 replies

Please or to participate in this conversation.