- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
This commit is contained in:
53
app/Services/ManagementLinkService.php
Normal file
53
app/Services/ManagementLinkService.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Repositories\ManagementLink;
|
||||
|
||||
class ManagementLinkService
|
||||
{
|
||||
private $managementLinkRepository;
|
||||
|
||||
public function __construct(ManagementLink $managementLinkRepository)
|
||||
{
|
||||
$this->managementLinkRepository = $managementLinkRepository;
|
||||
}
|
||||
|
||||
public function save(array $data)
|
||||
{
|
||||
if (isset($data['id'])) {
|
||||
$management_links = $this->managementLinkRepository->findOrFail($data['id']);
|
||||
$management_links->update($data);
|
||||
} else {
|
||||
$management_links = $this->managementLinkRepository->create($data);
|
||||
}
|
||||
|
||||
return $management_links;
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$management_links = $this->managementLinkRepository->findOrFail($id);
|
||||
$management_links->delete();
|
||||
}
|
||||
|
||||
public function get($id)
|
||||
{
|
||||
return $this->managementLinkRepository->findOrFail($id);
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
return $this->managementLinkRepository->all();
|
||||
}
|
||||
|
||||
public function with(array $children)
|
||||
{
|
||||
return $this->managementLinkRepository->with($children)->get();
|
||||
}
|
||||
|
||||
public function getOneWith($id, array $children)
|
||||
{
|
||||
return $this->managementLinkRepository->with($children)->findOrFail($id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user