-3
$applicantAttr = [
            'name' => 'Taylor Otwell',
            'email' => 'vaibhav@coloredcow.com',
            'phone' => '123321',
            'college' => 'Sample college',
            'graduation_year' => '2018',
            'course' => 'Test Course',
            'linkedin' => 'https://github.com/coloredcow/employee-portal',
            'resume' => 'https://github.com/coloredcow/employee-portal',
            'form_data' => [
                'data 1' => 'Sample content 1',
                'data 2' => 'Sample content 2',
            ],
            'job_title' => $job->title,
        ];

how to make a function of this in php and then call it. After making a function then call it in another place.

1 Answers1

0

Create a function in helpers.php file in your app folder

function getCustomData()
{
    $applicantAttr = [
            'name' => 'Taylor Otwell',
            'email' => 'vaibhav@coloredcow.com',
            'phone' => '123321',
            'college' => 'Sample college',
            'graduation_year' => '2018',
            'course' => 'Test Course',
            'linkedin' => 'https://github.com/coloredcow/employee-portal',
            'resume' => 'https://github.com/coloredcow/employee-portal',
            'form_data' => [
                'data 1' => 'Sample content 1',
                'data 2' => 'Sample content 2',
            ],
            'job_title' => $job->title,
        ];
    return $applicantAttr;
}

and call this function as:

getCustomData();

For more details

Gufran Hasan
  • 8,910
  • 7
  • 38
  • 51