Last active
July 25, 2017 09:32
-
-
Save DuckThom/4fd72bac11b3799cd3a82ca89027512a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Services\Interfaces\ExportServiceInterface as ExportService; | |
class ExportController extends Controller | |
{ | |
protected $es; | |
public function __construct(ExportService $es) | |
{ | |
$this->es = $es; | |
} | |
public function exportRegistrations() | |
{ | |
$data = $this->es->registrations(); | |
/* Do stuff with the data */ | |
return; // Return a response | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use App\Services\Interfaces\ExportServiceInterface as ExportService; | |
class ExportRegistrationsCommand extends Command | |
{ | |
protected $es; | |
protected $signature = 'export:registrations'; | |
public function __construct(ExportService $es) | |
{ | |
$this->es = $es; | |
} | |
public function handle() | |
{ | |
$data = $this->es->registrations(); | |
/* Do stuff with the data */ | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Services; | |
use App\Services\Interfaces\ExportServiceInterface; | |
class ExportService implements ExportServiceInterface | |
{ | |
public function registrations() | |
{ | |
$data = []; | |
/* Do the query stuff */ | |
return $data; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Services\Interfaces; | |
interface ExportServiceInterface | |
{ | |
public function registrations(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use App\Services\ExportService; | |
use Illuminate\Support\ServiceProvider; | |
use App\Services\Interfaces\ExportServiceInterface; | |
class ExportServiceProvider extends ServiceProvider | |
{ | |
public function register() | |
{ | |
$this->app->bind(ExportServiceInterface::class, ExportService::class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment