https://dev.to/andrewsavetchuk #service-classes%E2%80%8B Service Classes A service class is a class that performs some business logic that you want to use in various places.

Some ideas for service classes: Service class responsible for sending SMS via Twilio.

Service class responsible for connecting to UptimeRobot APIs and retrieving data.

Here is an example of the App\Services\UptimeRobotAPI.php service class that is responsible for connecting to the UptimeRobot API and retrieving data: url = 'https://api.uptimerobot.com/v2/'; $this->http = $client; $this->headers = [ 'cache-control' => 'no-cache', 'content-type' => 'application/x-www-form-urlencoded', ]; } private function getResponse (string $uri = NULL) { // Making a GET request to UptimeRobot API using GuzzleHttp... } private function postResponse (string $uri = NULL, array $params = []) { // Making a POST request to UptimeRobot API using GuzzleHttp... } public function getMonitors () { return $this->getResponse('getMonitors'); }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners