How to add custom ini_set in Laravel

I want to export data from a view into csv file at live server but whenever I run it I get this error:

Maximum execution time of 30 seconds exceeded

And here is the Export Class:

class StudentExportView implements FromView
     * @return IlluminateSupportCollection
    public function view(): View
        $student = new Student();
        $students = $student->searchStudents()->paginate(10);
        $custom = new Student();
        $customs = $custom->all();
        return view('admin.students.custom', compact('students','customs'));

Actually there is a large amount of data, that’s why this error occured. But they say if I add ini_set('max_execution_time', 300); I can get rid of this error.

So the question is where to add this custom ini_set? I mean at the Controller or Export Class?

Is there any solution for this to run this code on live server?

I would really appreciate any idea or suggestion from you guys..

Thanks in advance.

Source: Ask PHP