0
Good morning, I’m doing a function so I can alter a data in a database table. That is, I have 4 data recorded in my database table where the main is 'yes', when recording a fifth data, the second oldest data has to go to 'no' in main.
public function removeMain(){
$news = News::Where('main' == 'Sim')->get();
if(count($news) == 4){
$news = News::Where('id','=', $news[2]->id)->first();
$news->main = 'Não';
}
}
The code I already have is this but it still doesn’t change the data in main. Can someone give me a help?
Thanks for the help!
– user187363