first change

This commit is contained in:
2025-07-27 17:40:56 +05:45
commit f8b9a6725b
3152 changed files with 229528 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace Modules\CourseFinder\Services;
use Illuminate\Support\Facades\DB;
use Modules\CourseFinder\Models\Coop;
class CoopService
{
public function getAllCategories()
{
$query = Coop::query();
return $query->get();
}
public function storeCoop(array $coopData): Coop
{
return DB::transaction(function () use ($coopData) {
$coop = Coop::create($coopData);
return $coop;
});
}
public function getCoopById(int $id)
{
return Coop::findOrFail($id);
}
public function updateCoop(int $id, array $coopData)
{
$coop = $this->getCoopById($id);
return DB::transaction(function () use ($coop, $coopData) {
$coop->update($coopData);
return $coop;
});
}
public function deleteCoop(int $id)
{
return DB::transaction(function () use ($id) {
$coop = $this->getCoopById($id);
$coop->delete();
return true;
});
}
}