Skip to content

Commit

Permalink
Merge pull request #15 from billalxcode/dev
Browse files Browse the repository at this point in the history
Update feature
  • Loading branch information
billalxcode authored Nov 4, 2023
2 parents 4a68932 + 44519c0 commit b02fd25
Show file tree
Hide file tree
Showing 62 changed files with 2,153 additions and 1,077 deletions.
32 changes: 32 additions & 0 deletions app/Console/Commands/MasterImport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Console\Commands;

use App\Imports\MasterImport as ImportsMasterImport;
use Illuminate\Console\Command;
use Maatwebsite\Excel\Facades\Excel;

class MasterImport extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:master-import';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Execute the console command.
*/
public function handle()
{
Excel::import(new ImportsMasterImport, "excel/MS.T-MASTER.xlsx");
}
}
8 changes: 5 additions & 3 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public function register(): void
}
});

$this->renderable(function (ValidationException $e) {
throw new ResponseError($e->getMessage());
});
// $this->renderable(function (ValidationException $e, Request $request) {
// if ($request->is('api/*')) {
// throw new ResponseError($e->getMessage());
// }
// });

$this->reportable(function (Throwable $e) {
//
Expand Down
66 changes: 66 additions & 0 deletions app/Http/Controllers/Operator/JadwalPelajaranController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace App\Http\Controllers;

use App\Models\JadwalPelajaran;
use App\Http\Requests\StoreJadwalPelajaranRequest;
use App\Http\Requests\UpdateJadwalPelajaranRequest;

class JadwalPelajaranController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreJadwalPelajaranRequest $request)
{
//
}

/**
* Display the specified resource.
*/
public function show(JadwalPelajaran $jadwalPelajaran)
{
//
}

/**
* Show the form for editing the specified resource.
*/
public function edit(JadwalPelajaran $jadwalPelajaran)
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(UpdateJadwalPelajaranRequest $request, JadwalPelajaran $jadwalPelajaran)
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy(JadwalPelajaran $jadwalPelajaran)
{
//
}
}
75 changes: 75 additions & 0 deletions app/Http/Controllers/Operator/MataPelajaranController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace App\Http\Controllers\Operator;

use App\Http\Controllers\Controller;
use App\Models\MataPelajaran;
use App\Http\Requests\StoreMataPelajaranRequest;
use App\Http\Requests\UpdateMataPelajaranRequest;

class MataPelajaranController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$mapels = MataPelajaran::all();

return view('operator.mapel.home', [
'mapels' => $mapels
]);
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreMataPelajaranRequest $request)
{
$data = $request->validated();

MataPelajaran::create($data);

return redirect()->back()->with('success', 'data berhasil ditambahkan');
}

/**
* Display the specified resource.
*/
public function show(MataPelajaran $mataPelajaran)
{
//
}

/**
* Show the form for editing the specified resource.
*/
public function edit(MataPelajaran $mataPelajaran)
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(UpdateMataPelajaranRequest $request, MataPelajaran $mataPelajaran)
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy(MataPelajaran $mataPelajaran)
{
//
}
}
22 changes: 18 additions & 4 deletions app/Http/Controllers/Operator/SiswaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
namespace App\Http\Controllers\Operator;

use App\Http\Controllers\Controller;
use App\Http\Requests\StoreImportSiswaRequest;
use App\Models\Siswa;
use App\Http\Requests\StoreSiswaRequest;
use App\Http\Requests\UpdateSiswaRequest;
use App\Imports\SiswaImport;
use App\Models\Kehadiran;
use App\Models\Ruangan;
use Illuminate\Support\Arr;
use Maatwebsite\Excel\Facades\Excel;

class SiswaController extends Controller
{
Expand Down Expand Up @@ -46,27 +49,38 @@ public function store(StoreSiswaRequest $request)
return redirect()->back()->with('success', 'data berhasil ditambahkan.');
}

/**
* Import data from XLSX
*/

public function import(StoreImportSiswaRequest $storeImportSiswaRequest) {
$storeImportSiswaRequest->validated();
Excel::import(new SiswaImport, $storeImportSiswaRequest->file('file'));

return redirect()->back()->with('success', 'data berhasil disimpan');
}

/**
* Display the specified resource.
*/
public function show($siswa_id)
{
$siswa = Siswa::find($siswa_id);

$kehadiran = [];

$kehadiran['sakit'] = Kehadiran::siswax($siswa->id)->sakit()->get();
$kehadiran['izin'] = Kehadiran::siswax($siswa->id)->izin()->get();
$kehadiran['alpha'] = Kehadiran::siswax($siswa->id)->alpha()->get();
$kehadiran['bolos'] = Kehadiran::siswax($siswa->id)->bolos()->get();

$kehadiran['jumlah_sakit'] = Kehadiran::siswax($siswa->id)->sakit()->count();
$kehadiran['jumlah_izin'] = Kehadiran::siswax($siswa->id)->izin()->count();
$kehadiran['jumlah_alpha'] = Kehadiran::siswax($siswa->id)->alpha()->count();
$kehadiran['jumlah_bolos'] = Kehadiran::siswax($siswa->id)->bolos()->count();

$siswa->setAttribute('kehadiran', (object) $kehadiran);

return view('operator.siswa.detail', [
'siswa' => $siswa
]);
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/Operator/TenagaPendidikController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\TenagaPendidik;
use App\Http\Requests\StoreTenagaPendidikRequest;
use App\Http\Requests\UpdateTenagaPendidikRequest;
use App\Models\MataPelajaran;

class TenagaPendidikController extends Controller
{
Expand All @@ -15,9 +16,11 @@ class TenagaPendidikController extends Controller
public function index()
{
$data_tenaga_pendidik = TenagaPendidik::all();
$data_mapels = MataPelajaran::all();

return view('operator.tenaga-pendidik.home', [
'data_tenaga_pendidik' => $data_tenaga_pendidik
'data_tenaga_pendidik' => $data_tenaga_pendidik,
'mapels' => $data_mapels
]);
}

Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/Operator/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
namespace App\Http\Controllers\Operator;

use App\Http\Controllers\Controller;
use App\Http\Requests\StoreUserImportRequest;
use App\Http\Requests\StoreUserRequest;
use App\Imports\MasterImport;
use App\Imports\UserRuanganImport;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Maatwebsite\Excel\Facades\Excel;
use Spatie\Permission\Models\Role;

class UserController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ruangan/KehadiranController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function index() {
$user = Auth::user();
$data_kehadiran = Kehadiran::where('ruangan_id', $user->ruangan->id)->whereDate('created_at', Carbon::today())->get();
$data_siswas = Siswa::where('ruangan_id', $user->ruangan->id)->orderBy('nama')->get();

return view('ruangan.kehadiran.home', [
'data_kehadiran' => $data_kehadiran,
'data_siswas' => $data_siswas
Expand Down
33 changes: 33 additions & 0 deletions app/Http/Requests/StoreImportSiswaRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rules\File;

class StoreImportSiswaRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return Auth::check();
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'file' => [
'required',
File::types(['xlsx', 'xls'])
]
];
}
}
28 changes: 28 additions & 0 deletions app/Http/Requests/StoreJadwalPelajaranRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreJadwalPelajaranRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
//
];
}
}
4 changes: 2 additions & 2 deletions app/Http/Requests/StoreKehadiranAbsenRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function rules(): array
return [
'siswa_id' => 'required|exists:siswas,id',
'ruangan_id' => 'required|exists:ruangans,id',
'status' => 'required|string|in:izin,sakit,alpha',
'keterangan' => 'required|string',
'status' => 'required|string|in:izin,sakit,alpha,bolos',
'keterangan' => 'nullable|string',
'file' => 'required|image|max:20480'
];
}
Expand Down
Loading

0 comments on commit b02fd25

Please sign in to comment.