How can I convert a String to an Int using Laravel SQL?
My SQL:
$playlistArr = ArtistPlaylist::where('artist_uuid', $this->artist_id)
->whereBetween('entry_date', [$previousMonthEndDate, $nowDate])
->selectRaw('sum(lastSubscriberCount) as lastSubscriberCountSum')
->selectRaw('entry_date')
->groupBy('entry_date')
->orderBy('entry_date')
->get();
I tried CAST, but it didn’t work:
$playlistArr = ArtistPlaylist::where('artist_uuid', $this->artist_id)
->whereBetween('entry_date', [$previousMonthEndDate, $nowDate])
->selectRaw('CAST(sum(lastSubscriberCount) as lastSubscriberCountSum) AS INT')
->selectRaw('entry_date')
->groupBy('entry_date')
->orderBy('entry_date')
->get()