Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\CRM\Contact;
- use App\CRM\Contact\Requests\ContactDestroy;
- use App\CRM\Contact\Requests\ContactStore;
- use App\CRM\Contact\Requests\ContactUpdate;
- use App\Abstractions\Controller;
- use EllipseSynergie\ApiResponse\Contracts\Response;
- use App\CRM\Contact\Contracts\ContactService as Service;
- use App\CRM\Contact\ContactTransformer;
- class ContactController extends Controller
- {
- protected $response;
- protected $service;
- public function __construct(
- Response $response,
- Service $service
- ) {
- $this->response = $response;
- $this->service = $service;
- }
- public function index()
- {
- $contacts = $this->service->get();
- return $this->response->withPaginator($contacts, new ContactTransformer());
- }
- public function show($id)
- {
- $contact = $this->service->show($id);
- return $this->response->withItem($contact, new ContactTransformer());
- }
- public function store(ContactStore $request)
- {
- $contact = $this->service->store($request);
- return $this->response->withItem($contact, new ContactTransformer());
- }
- public function update(ContactUpdate $request, $id)
- {
- $contact = $this->service->update($request, $id);
- return $this->response->withItem($contact, new ContactTransformer());
- }
- public function destroy(ContactDestroy $request, $id)
- {
- $contact = $this->service->destroy($id);
- return $this->response->withItem($contact, new ContactTransformer());
- }
- }
Add Comment
Please, Sign In to add comment