deepu07
1 month ago
344
6
General

Select Statement column cast string to integer

Posted 1 month ago by deepu07

Hi Mates, I'm in a scenario where I need to cast from string to integer in Select statement. I tried a couple of ways but it didn't work out for me. any help/suggestion that would be great. TIA

$students = Student::select([
            'id',
            'name',
	    'year',
            'subjects->subject5_number as subject5_number'
        ])
        ->where('year', 2019)
        ->orderBy('subject5_number')->get();

Please sign in or create an account to participate in this conversation.