After posting the article on the specific time and date, I need to hide it if expired_at column has a value. I just want to be removed in the view, not delete it.
Is there a way where I can just chain the hide part? Or it will be on a separate function?
@Jeyziii Sorry I just noticed that I had something wrong in my proposition of code.
You need to hide the articles which have an expiration date.
$latest_article=Article::whereDate('published_at', '<=', Carbon::now())
->whereNull('expired_at') // so you show only where the expiration date is null
->latest('published_at')
->limit(5)
->get();
If you need to check the expiration date to be less than the actual date, you need to add a condition around the expiration date.
@vincent15000 Sorry, my construction of sentence is wrong. What I mean is, I want the article to be hidden at the date and time set in the expired_at. Like after the article is posted, it will not shown in the front end when the date and time comes.