mirror of
https://gitlab.com/omair-personal/izyim.git
synced 2026-08-19 12:24:11 +00:00
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Contacts;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Resources\Contact as ContactResource;
|
|
use App\Classes\Constants;
|
|
use App\Classes\ControllersLogic\Contacts\ListContacts;
|
|
use App\Classes\ControllersLogic\Contacts\UpdateContact;
|
|
use App\Classes\ControllersLogic\Contacts\DeleteContact;
|
|
|
|
class ContactController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
* @param string $type
|
|
* @param string $reference
|
|
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
|
*/
|
|
public function index(string $type, string $reference) {
|
|
|
|
return (new ListContacts())->execute(Constants::MODULE_TYPES[$type], $reference);
|
|
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param string $type
|
|
* @param string $reference
|
|
* @return ContactResource
|
|
*/
|
|
public function store(Request $request, string $type, string $reference)
|
|
{
|
|
return (new UpdateContact())->execute($request, Constants::MODULE_TYPES[$type], $reference);
|
|
}
|
|
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param string $id
|
|
*
|
|
* @return ContactResource
|
|
*/
|
|
public function destroy(string $id): ContactResource {
|
|
|
|
return (new DeleteContact())->execute($id);
|
|
|
|
}
|
|
}
|