Skip to content

Commit

Permalink
serach social medi
Browse files Browse the repository at this point in the history
  • Loading branch information
ArdianS18 committed Nov 8, 2024
1 parent 253e61d commit b8fe7f9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/Contracts/Interfaces/RegulationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public function getAll(Request $request);
public function sum_point(mixed $id): mixed;
public function getRegulation(Request $request): mixed;
public function getOrder(): mixed;
public function latest(): mixed;
}
5 changes: 5 additions & 0 deletions app/Contracts/Repositories/RegulationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public function get(): mixed
return $this->model->query()->get();
}

public function latest(): mixed
{
return $this->model->query()->latest()->get();
}

public function sum_point(mixed $id): mixed
{
return $this->model->query()->where('id', $id)->get()->sum('point');
Expand Down
13 changes: 8 additions & 5 deletions app/Http/Controllers/Api/StafApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

use App\Contracts\Interfaces\EmployeeInterface;
use App\Contracts\Interfaces\EmployeeJournalInterface;
use App\Contracts\Interfaces\RegulationInterface;
use App\Contracts\Interfaces\SchoolPointInterface;
use App\Contracts\Interfaces\StudentInterface;
use App\Contracts\Interfaces\StudentRepairInterface;
use App\Contracts\Interfaces\StudentViolationInterface;
use App\Http\Controllers\Controller;
use App\Http\Resources\EmployeeJournalResource;
use App\Http\Resources\RegulationResource;
use App\Models\User;
use App\Services\EmployeeJournalService;
use Illuminate\Http\Request;
Expand All @@ -23,6 +25,7 @@ class StafApiController extends Controller
private EmployeeInterface $employee;
private EmployeeJournalService $journalService;
private EmployeeJournalInterface $employeeJournal;
private RegulationInterface $regulation;

public function __construct(
StudentViolationInterface $studentViolation,
Expand All @@ -32,6 +35,7 @@ public function __construct(
EmployeeInterface $employee,
EmployeeJournalService $journalService,
EmployeeJournalInterface $employeeJournal,
RegulationInterface $regulation,
)
{
$this->studentViolation = $studentViolation;
Expand All @@ -41,6 +45,7 @@ public function __construct(
$this->employee = $employee;
$this->journalService = $journalService;
$this->employeeJournal = $employeeJournal;
$this->regulation = $regulation;
}

/**
Expand Down Expand Up @@ -106,14 +111,12 @@ public function max_point()

public function list_violation()
{

return response()->json(['status' => 'success', 'message' => "Berhasil mengambil data",'code' => 200, 'data' => [

]]);
$regulations = $this->regulation->latest();
return response()->json(['status' => 'success', 'message' => "Berhasil mengambil data",'code' => 200, 'data' => RegulationResource::collection($regulations),]);
}

public function list_repair()
{

}
}
22 changes: 22 additions & 0 deletions app/Http/Resources/RegulationResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class RegulationResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'name_violation' => $this->violation,
'point' => $this->point,
];
}
}
1 change: 1 addition & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
Route::post('staf/create-journal/{user}', [StafApiController::class, 'create_journal']);
Route::get('staf/overview-header', [StafApiController::class, 'overview_header']);
Route::get('staf/max-point', [StafApiController::class, 'max_point']);
Route::get('staf/list-violation', [StafApiController::class, 'list_violation']);

Route::get('lesson-schedule/{user}', [LessonScheduleApiController::class, 'index']);
Route::get('teacher-journal/{lessonSchedule}', [LessonScheduleApiController::class, 'create']);
Expand Down

0 comments on commit b8fe7f9

Please sign in to comment.