intial commit

This commit is contained in:
2026-06-07 19:10:00 +07:00
commit 37bf240d23
230 changed files with 37141 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
server {
listen 80;
root /var/www/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
+33
View File
@@ -0,0 +1,33 @@
FROM node:16-alpine AS node-builder
WORKDIR /build
COPY package.json package-lock.json tailwind.config.js webpack.mix.js ./
RUN npm install
COPY resources/ resources/
RUN npm run production
FROM php:8.1-fpm-alpine
RUN apk add --no-cache \
git unzip libpng libwebp libjpeg libxpm libxml2 \
&& docker-php-ext-install bcmath gd mbstring pdo_mysql xml
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
COPY . .
COPY --from=node-builder /build/public/css /var/www/public/css
COPY --from=node-builder /build/public/js /var/www/public/js
COPY --from=node-builder /build/public/mix-manifest.json /var/www/public/mix-manifest.json
RUN composer install --no-dev --optimize-autoloader && \
chmod -R 775 storage bootstrap/cache && \
chown -R www-data:www-data storage bootstrap/cache public/img
COPY .docker/php/entrypoint.sh /entrypoint.sh
COPY .docker/php/php.ini /usr/local/etc/php/conf.d/custom.ini
RUN chmod +x /entrypoint.sh
EXPOSE 9000
ENTRYPOINT ["/entrypoint.sh"]
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
set -e
echo "Waiting for database connection..."
until php -r "try { new PDO('mysql:host=${DB_HOST};port=${DB_PORT}', '${DB_USERNAME}', '${DB_PASSWORD}'); echo 'ok'; } catch(PDOException \$e) { echo \$e->getMessage(); exit(1); }" 2>/dev/null | grep -q 'ok'; do
sleep 3
done
echo "Database connected."
php artisan migrate --force --isolated
php artisan storage:link --force || true
if [ "${APP_ENV}" = "production" ]; then
php artisan config:cache
php artisan route:cache
php artisan view:cache
fi
exec php-fpm
+4
View File
@@ -0,0 +1,4 @@
upload_max_filesize = 20M
post_max_size = 20M
memory_limit = 256M
max_execution_time = 300
+13
View File
@@ -0,0 +1,13 @@
.git
.gitattributes
.gitignore
vendor
node_modules
storage/app
public/img
humicpro_gizibalita.sql
error_log
.editorconfig
.styleci.yml
.DS_Store
*.md
+18
View File
@@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4
+52
View File
@@ -0,0 +1,52 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
+10
View File
@@ -0,0 +1,10 @@
* text=auto
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
+96
View File
@@ -0,0 +1,96 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.idea
/.vscode
# Created by https://www.toptal.com/developers/gitignore/api/laravel,composer,vim
# Edit at https://www.toptal.com/developers/gitignore?templates=laravel,composer,vim
### Composer ###
composer.phar
/vendor/
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
### Laravel ###
node_modules/
npm-debug.log
yarn-error.log
# Laravel 4 specific
bootstrap/compiled.php
app/storage/
# Laravel 5 & Lumen specific
public/storage
public/hot
# Laravel 5 & Lumen specific with changed public path
public_html/storage
public_html/hot
storage/*.key
.env
Homestead.yaml
Homestead.json
/.vagrant
.phpunit.result.cache
### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
# End of https://www.toptal.com/developers/gitignore/api/laravel,composer,vim
# Compiled assets (built by npm run production)
/public/css
/public/js
/public/mix-manifest.json
# Logs
storage/logs/*.log
error_log
public/error_log
# cPanel leftovers
apigizibalita.telekardiologi.com/
cgi-bin/
# IDE / OS files
.idea/
.vscode/
.DS_Store
*.swp
*.swo
*~
+18
View File
@@ -0,0 +1,18 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
<IfModule mod_headers.c>
# Izinkan semua origin (atau ganti * dengan daftar origin spesifik)
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"
Header set Access-Control-Max-Age "86400"
# Tangani permintaan OPTIONS untuk preflight
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
</IfModule>
</IfModule>
+14
View File
@@ -0,0 +1,14 @@
php:
preset: laravel
version: 8
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
+11
View File
@@ -0,0 +1,11 @@
# Peengmas Monitoring Stunting Telkom University
## RUN
- make dependecies:
- `composer install`
- set db migration
- `php artisan migrate`
- make ui dependencies
- `npm run prod` for production
- `npm run dev` for development
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\StatistikAnak;
use App\Models\Anak;
use Carbon\Carbon;
class DeleteAnak extends Command
{
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
protected $signature = 'anak:delete';
protected $description = 'Delete anak yang umurnya 59 bulan keatas.';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$fiveNineMonthsAgo = Carbon::now()->subMonths(59)->format('Y-m-d');
$anakToDelete = Anak::whereDate('tanggal_lahir', '<=', $fiveNineMonthsAgo)->get();
foreach ($anakToDelete as $anak) {
StatistikAnak::where('id_anak', $anak->id)->delete();
$anak->delete();
}
$this->info('Users deleted successfully.');
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class DeleteUsers extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
return 0;
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
// $schedule->command('anak:delete')->dailyAt('00:00')->timezone('Asia/Jakarta');;
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
+68
View File
@@ -0,0 +1,68 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
$this->renderable(function (MethodNotAllowedHttpException $e, $request) {
if ($request->is('api/*') ) {
return response()->json([
"message" => "method not allowed"
], 405);
}
});
$this->renderable(function (MethodNotAllowedException $e, $request) {
if ($request->is('api/*') ) {
return response()->json([
"message" => "method not allowed"
], 405);
}
});
$this->renderable(function (NotFoundHttpException $e, $request) {
if ($request->is('api/*')) {
return response()->json([
"message" => "not found",
], 404);
}
});
}
}
+75
View File
@@ -0,0 +1,75 @@
<?php
namespace App\Http\Controllers;
use App\Models\Anak;
use Illuminate\Http\Request;
class AnakController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$anak = Anak::find($id);
if (empty($anak)) {
redirect('/dashboard');
}
$response = [
'anak' => $anak,
'statistik' => $anak->statistik()->orderBy('created_at', 'desc')->get()
];
return view('detail-anak', $response);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Anak $anak
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Anak $anak)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Anak $anak
* @return \Illuminate\Http\Response
*/
public function destroy(Anak $anak)
{
//
}
}
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace App\Http\Controllers\Api;
use Config;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class AiController extends ApiBaseController
{
public function searchArticle(){
$apiKey = 'AIzaSyDmyFs7X7a55UymSNxM7_eUfNmeqmM1XN8';
$searchEngineId = '000888210889775888983:pqb3ch1ewhg';
$query = 'artikel balita sehat';
$countryCode = 'ID';
$url = 'https://www.googleapis.com/customsearch/v1?key=' . $apiKey . '&cx=' . $searchEngineId . '&q=' . urlencode($query) . '&cr=' . $countryCode;
$response = file_get_contents($url);
$results = json_decode($response);
if (isset($results->error)) {
echo 'Error: ' . $results['error']['message'];
} else {
$searchResults = [];
foreach ($results->items as $item) {
$searchResult = [
'title' => $item->title,
'link' => $item->link,
'snippet' => $item->snippet
];
$searchResults[] = $searchResult;
}
}
return $this->successResponse("data artikel", $searchResults);
}
// public function searchArticle(){
// $query = 'balita sehat';
// $url = 'https://news.google.com/rss/search?q=' . urlencode($query);
// $xml = file_get_contents($url);
// $feed = simplexml_load_string($xml);
// if ($feed) {
// $searchResults = [];
// foreach ($feed->channel->item as $item) {
// $searchResult = [
// 'title' => $item->title->__toString(),
// 'link' => $item->link->__toString()
// ];
// $searchResults[] = $searchResult;
// }
// } else {
// echo 'Failed to load feed.';
// }
// return $this->successResponse("data artikel", $searchResults);
// }
}
+663
View File
@@ -0,0 +1,663 @@
<?php
namespace App\Http\Controllers\Api;
use App\Models\Anak;
use App\Models\StatistikAnak;
use App\Http\Resources\StatistikResource;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
use DateTime;
use DB;
class AnakController extends ApiBaseController
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function indexWithOrangTua()
{
$orangTua = User::getUser(Auth::user());
$fiveNineMonthsAgo = Carbon::now()->subMonths(60)->format('Y-m-d');
$anak = $orangTua->anak()->whereDate('tanggal_lahir', '>', $fiveNineMonthsAgo)->orderBy('tanggal_lahir', 'asc')->get();
foreach ($anak as $key => $item) {
$item->anak_ke = $key + 1;
}
return $this->successResponse("data anak", $anak);
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function indexWithKaderPosyandu()
{
$kaderPosyandu = User::getUser(Auth::user());
$fiveNineMonthsAgo = Carbon::now()->subMonths(60)->format('Y-m-d');
// Eager load the orangTua relationship and filter only approved children
$anak = $kaderPosyandu->posyandu->anak()
->whereDate('tanggal_lahir', '>', $fiveNineMonthsAgo)
->where('status', 1) // Filter hanya anak yang di-approve
->with('orangTua') // Use correct relationship name
->get();
foreach ($anak as $item) {
$statistik = $item->statistik()->orderBy('date', 'desc')->get();
if (count($statistik) == 0) {
$item->status_berat_terakhir = null;
$item->status_tinggi_terakhir = null;
$item->status_lingkaran_kepala_terakhir = null;
$item->status_gizi_terakhir = null;
// Use nama_orang_tua from Anak, fallback to orangTua->nama
$item->nama_ortu = $item->nama_orang_tua ?? ($item->orangTua ? $item->orangTua->nama : null);
continue;
}
$statistik = StatistikResource::collection($statistik);
$json = json_encode($statistik[0]);
$statik = json_decode($json);
$item->status_berat_terakhir = $statik->statistik->berat;
$item->status_tinggi_terakhir = $statik->statistik->tinggi;
$item->status_lingkaran_kepala_terakhir = $statik->statistik->lingkar_kepala;
$item->status_gizi_terakhir = $statik->statistik->gizi;
// Use nama_orang_tua from Anak, fallback to orangTua->nama
$item->nama_ortu = $item->nama_orang_tua ?? ($item->orangTua ? $item->orangTua->nama : null);
}
return $this->successResponse("data anak", $anak);
}
public function showOrangTua()
{
$kader = User::getUser(Auth::user());
if (!$kader->posyandu) {
return $this->errorResponse("Kader tidak terkait dengan posyandu", 404);
}
// Get parents with role 'ORANG_TUA' and associated with the kader's posyandu
$orangTua = User::whereHas('posyandu', function ($query) use ($kader) {
$query->where('id', $kader->posyandu->id);
})
->whereHas('role', function ($query) {
$query->where('role', 'ORANG_TUA');
})
->where('id', '!=', $kader->id)
->get();
if ($orangTua->isEmpty()) {
return $this->successResponse("Tidak ada data orang tua", []);
}
return $this->successResponse("data orang tua", $orangTua);
}
public function approveOrangTua(Request $request, $id)
{
$kader = User::getUser(Auth::user());
if (!$kader->posyandu) {
return $this->errorResponse("Kader tidak terkait dengan posyandu", 404);
}
// Find the parent with the same posyandu and role 'ORANG_TUA'
$orangTua = User::whereHas('posyandu', function ($query) use ($kader) {
$query->where('id', $kader->posyandu->id);
})
->whereHas('role', function ($query) {
$query->where('role', 'ORANG_TUA');
})
->where('id', $id)
->firstOrFail();
// Validate the status input
$request->validate([
'status' => 'required|in:0,1',
]);
// Update the status
$orangTua->status = $request->status;
$orangTua->save();
return $this->successResponse("Status orang tua berhasil diperbarui", $orangTua);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function storeWithOrangTua(Request $request)
{
$user = Auth::user();
$validator = validator($request->all(), [
'nama' => ['required', 'string', 'min:3'],
'panggilan' => ['string'],
'tanggal_lahir' => ['required', 'date'],
'gender' => ['required', Rule::in(['LAKI_LAKI', 'PEREMPUAN'])],
'image' => ['string'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Gagal Input Data Anak", $validator->errors());
}
$anak = Anak::create([
'nama' => $request->nama,
'panggilan' => $request->panggilan,
'tanggal_lahir' => $request->tanggal_lahir,
'alamat' => $request->alamat,
'gender' => $request->gender,
'image' => $request->image,
'id_posyandu' => $user->id_posyandu,
'id_desa' => $user->id_desa,
'id_orang_tua' => $user->id,
'status'=>false
]);
$anak->save();
return $this->successResponse("Success");
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function storeWithKaderPosyanduExcel(Request $request)
{
$user = Auth::user();
$validator = validator($request->all(), [
'file' => ['required', 'file', 'mimes:xlsx,xls,csv'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("validation failed", $validator->errors());
}
$file = $request->file('file');
\Log::info('Uploaded file details:', [
'name' => $file->getClientOriginalName(),
'extension' => $file->getClientOriginalExtension(),
'mime' => $file->getMimeType(),
]);
$extension = strtolower($file->getClientOriginalExtension());
$path = $file->storeAs('temp', $file->getClientOriginalName(), 'local');
$fullPath = storage_path('app/' . $path);
try {
// Use the injected Excel instance
$data = $this->excel->toArray(null, $fullPath, null, $readerType = null);
if (empty($data) || empty($data[0])) {
return $this->errorValidationResponse("Invalid file", ["File is empty or not in the expected format."]);
}
$z_score = new HitungZScoreController();
foreach ($data[0] as $row) {
if ($row[0] != 'No' && !empty($row[0])) {
$id_ortu = DB::table('users')->where('nama', '=', $row[6])->value('id');
if (!$id_ortu) {
\Log::error("Parent not found for name: {$row[6]}");
continue;
}
$gender = '';
if (strtolower($row[5]) === 'l') {
$gender = 'LAKI_LAKI';
} elseif (strtolower($row[5]) === 'p') {
$gender = 'PEREMPUAN';
}
$birthDate = DateTime::createFromFormat('Y-m-d', $row[3]);
$statDate = DateTime::createFromFormat('Y-m-d', $row[7]);
if (!$birthDate || !$statDate) {
\Log::error("Invalid date format for row: " . json_encode($row));
continue;
}
DB::beginTransaction();
try {
$anak = Anak::create([
'nama' => $row[1],
'panggilan' => $row[2],
'tanggal_lahir' => $birthDate,
'alamat' => $row[4],
'gender' => $gender,
'id_orang_tua' => $id_ortu,
'id_posyandu' => $user->id_posyandu,
'id_desa' => $user->id_desa,
]);
$hitung_berat = $z_score->HitungZScoreBerat($row[8]);
$hitung_tinggi = $z_score->HitungZScoreTinggi($row[9]);
$hitung_LiLA = $z_score->HitungZScoreLiLA($row[10]);
StatistikAnak::create([
'id_anak' => $anak->id,
'date' => $statDate,
'berat' => $row[8],
'tinggi' => $row[9],
'lingkar_kepala' => $row[10],
'z_score_berat' => $hitung_berat['z_score_berat'],
'z_score_tinggi' => $hitung_tinggi['z_score_tinggi'],
'z_score_lingkar_kepala' => $hitung_LiLA['z_score_lingkar_kepala'],
'status_berat_badan' => $hitung_berat['status_berat_badan'],
'status_tinggi_badan' => $hitung_tinggi['status_tinggi_badan'],
'status_lingkar_kepala' => $hitung_LiLA['status_lingkar_kepala'],
]);
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
\Log::error("Error processing row: " . $e->getMessage());
continue;
}
}
}
\File::delete($fullPath);
return $this->successResponse("Success");
} catch (\Exception $e) {
\File::delete($fullPath);
\Log::error("Excel processing error: " . $e->getMessage());
return $this->errorValidationResponse("Error processing file", [$e->getMessage()]);
}
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function storeWithKaderPosyandu(Request $request)
{
$user = Auth::user();
$validator = validator($request->all(), [
'nama' => ['required', 'string', 'min:3'],
'panggilan' => ['string'],
'tanggal_lahir' => ['required', 'date'],
'alamat' => ['string'],
'gender' => ['required', Rule::in(['LAKI_LAKI', 'PEREMPUAN'])],
'image' => ['string'],
'id_orang_tua' => ['required'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Gagal Input Data Anak", $validator->errors());
}
$anak = new Anak;
$anak->fill([
'nama' => $request->nama,
'panggilan' => $request->panggilan,
'tanggal_lahir' => $request->tanggal_lahir,
'alamat' => $request->alamat,
'gender' => $request->gender,
'image' => $request->image,
'id_orang_tua' => $request->id_orang_tua,
'id_posyandu' => $user->id_posyandu,
'id_desa' => $user->id_desa,
'status' => true, // Set status to true by default
]);
$anak->save();
return $this->successResponse("Success");
}
/**
* Display the specified resource.
*
* @param \App\Models\Anak $anak
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$anak = Anak::findOrFail($id);
return $this->successResponse("Data Anak", $anak);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Anak $anak
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$anak = Anak::findOrFail($id);
$anak->fill($request->all());
$anak->save();
return $this->successResponse("Success Update Data Anak", $anak);
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Anak $anak
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$statistik = StatistikAnak::where('id_anak', $id);
$statistik->delete();
$anak = Anak::findOrFail($id);
$anak->delete();
return $this->successResponse("Success Delete Data Anak");
}
/**
* Export data anak to CSV without statistics.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function exportDataAnakCSV2(Request $request)
{
$kaderPosyandu = User::getUser(Auth::user());
$fiveNineMonthsAgo = Carbon::now()->subMonths(60)->format('Y-m-d');
// Query anak data
$query = $kaderPosyandu->posyandu->anak()
->whereDate('tanggal_lahir', '>', $fiveNineMonthsAgo)
->with('orangTua');
$anak = $query->get();
if ($anak->isEmpty()) {
return $this->errorNotFound("Data anak tidak tersedia untuk diekspor");
}
// Get posyandu name
$posyanduName = $kaderPosyandu->posyandu->nama ?? 'Posyandu Tidak Diketahui';
// Format data for export
$data = $anak->map(function ($item) {
return [
'nama' => $item->nama,
'tanggal_lahir' => $item->tanggal_lahir,
'umur' => Carbon::now()->diffInMonths(Carbon::parse($item->tanggal_lahir)) . ' Bulan',
'gender' => $item->gender === 'LAKI_LAKI' ? 'Laki-laki' : 'Perempuan',
'alamat' => $item->alamat,
'nama_ortu' => $item->nama_orang_tua ?? ($item->orangTua ? $item->orangTua->nama : null),
];
});
$fileName = 'data-anak.csv';
$headers = [
"Content-type" => "text/csv",
"Content-Disposition" => "attachment; filename=$fileName",
"Pragma" => "no-cache",
"Cache-Control" => "must-revalidate, post-check=0, pre-check=0",
"Expires" => "0",
];
$columns = [
'Nama Anak',
'Tanggal Lahir',
'Umur',
'Jenis Kelamin',
'Alamat',
'Nama Orang Tua',
];
$callback = function () use ($posyanduName, $columns, $data) {
$file = fopen('php://output', 'w');
// Write posyandu name
fputcsv($file, ['Posyandu: ' . $posyanduName]);
// Write empty row
fputcsv($file, []);
// Write column headers
fputcsv($file, $columns);
// Write data
foreach ($data as $row) {
fputcsv($file, [
$row['nama'],
$row['tanggal_lahir'],
$row['umur'],
$row['gender'],
$row['alamat'],
$row['nama_ortu'],
]);
}
fclose($file);
};
return response()->stream($callback, 200, $headers);
}
public function exportDataAnakCSV(Request $request)
{
// Validate input
$validator = validator($request->all(), [
'desa' => ['required', 'integer'], // Ensure desa is provided
'bulan' => ['required', 'string'], // Ensure bulan is provided
'tahun' => ['required', 'string'], // Ensure tahun is provided
'id' => ['nullable', 'string'], // Allow id to be nullable or string (for "all" or specific id_posyandu)
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Gagal Ekspor Data", $validator->errors());
}
// Query children based on desa (village)
$anak = Anak::where('id_desa', $request->desa);
// If id is provided and not "all", filter by specific posyandu
if (!is_null($request->id) && $request->id !== 'all') {
$anak = $anak->where('id_posyandu', $request->id);
}
// Fetch the data
$anak = $anak->get();
// Collect statistics for the specified month and year
$collection = [];
foreach ($anak as $data) {
foreach ($data->statistik as $statistik) {
if (Carbon::parse($statistik->date)->month == $request->bulan && Carbon::parse($statistik->date)->year == $request->tahun) {
array_push($collection, $statistik);
}
}
}
// Check if data is available
if (empty($collection)) {
return $this->errorNotFound("Data Export tidak tersedia");
}
// Define CSV filename and headers
$fileName = 'data-anak.csv';
$headers = [
"Content-type" => "text/csv",
"Content-Disposition" => "attachment; filename=$fileName",
"Pragma" => "no-cache",
"Cache-Control" => "must-revalidate, post-check=0, pre-check=0",
"Expires" => "0"
];
// Define CSV columns
$columns = [
'Nama',
'JK',
'Tanggal Lahir',
'Nama Orang Tua',
'Posyandu',
'Alamat',
'Tanggal Pengukuran',
'Berat',
'Tinggi',
'Lingkar Kepala',
'BB/U',
'Z - BB/U',
'TB/U',
'Z - TB/U',
'LK/U',
'Z - LK/U'
];
// Stream the CSV
$callback = function () use ($collection, $columns) {
$file = fopen('php://output', 'w');
fputcsv($file, $columns);
foreach ($collection as $data) {
$row = [
'Nama' => $data->anak->nama ?? 'N/A',
'JK' => $data->anak->gender ?? 'N/A',
'Tanggal Lahir' => $data->anak->tanggal_lahir ?? 'N/A',
'Nama Orang Tua' => $data->anak->orangTua->nama ?? 'N/A',
'Posyandu' => $data->anak->posyandu->nama ?? 'N/A',
'Alamat' => $data->anak->posyandu->alamat ?? 'N/A',
'Tanggal Pengukuran' => $data->date ?? 'N/A',
'Berat' => $data->berat ?? 'N/A',
'Tinggi' => $data->tinggi ?? 'N/A',
'Lingkar Kepala' => $data->lingkar_kepala ?? 'N/A',
'BB/U' => $this->beratBadan($data->z_score_berat) ?? 'N/A',
'ZS - BB/U' => $data->z_score_berat ?? 'N/A',
'TB/U' => $this->tinggiBadan($data->z_score_tinggi) ?? 'N/A',
'ZS - TB/U' => $data->z_score_tinggi ?? 'N/A',
'LK/U' => $this->lingkarKepala($data->z_score_lingkar_kepala) ?? 'N/A',
'ZS - LK/U' => $data->z_score_lingkar_kepala ?? 'N/A'
];
fputcsv($file, [
$row['Nama'],
$row['JK'],
$row['Tanggal Lahir'],
$row['Nama Orang Tua'],
$row['Posyandu'],
$row['Alamat'],
$row['Tanggal Pengukuran'],
$row['Berat'],
$row['Tinggi'],
$row['Lingkar Kepala'],
$row['BB/U'],
$row['ZS - BB/U'],
$row['TB/U'],
$row['ZS - TB/U'],
$row['LK/U'],
$row['ZS - LK/U']
]);
}
fclose($file);
};
return response()->stream($callback, 200, $headers);
}
public function beratBadan($ZScoreBerat)
{
if ($ZScoreBerat <= -3) {
return 'Sangat Kurus';
} else if ($ZScoreBerat > -3 && $ZScoreBerat <= -2) {
return 'Kurus';
} else if ($ZScoreBerat > -2 && $ZScoreBerat <= 2) {
return 'Normal';
} else if ($ZScoreBerat > 2) {
return 'Gemuk';
}
}
public function tinggiBadan($ZScoreTinggi)
{
if ($ZScoreTinggi <= -3) {
return 'Sangat Pendek';
} else if ($ZScoreTinggi > -3 && $ZScoreTinggi <= -2) {
return 'Pendek';
} else if ($ZScoreTinggi > -2 && $ZScoreTinggi <= 2) {
return 'Normal';
} else if ($ZScoreTinggi > 2) {
return 'Tinggi';
}
}
public function lingkarKepala($ZScoreLingkarKepala)
{
if ($ZScoreLingkarKepala > 2) {
return 'Makrosefali';
} else if ($ZScoreLingkarKepala > -2 && $ZScoreLingkarKepala <= 2) {
return 'Normal';
} else if ($ZScoreLingkarKepala < -2) {
return 'Mikrosefali';
}
}
public function approveAllAnak()
{
try {
// Update semua anak menjadi status = true (1)
Anak::query()->update(['status' => true]);
return $this->successResponse("Semua data anak berhasil disetujui (status = true).");
} catch (\Exception $e) {
return $this->errorResponse("Gagal mengupdate status anak", 500, $e->getMessage());
}
}
public function approveAnak($id)
{
try {
// Find the child by ID
$anak = Anak::find($id);
// Check if the child exists
if (!$anak) {
return $this->errorResponse("Data anak tidak ditemukan", 404);
}
// Update the child's status to true (1)
$anak->update(['status' => true]);
return $this->successResponse("Data anak berhasil disetujui (status = true).");
} catch (\Exception $e) {
return $this->errorResponse("Gagal mengupdate status anak", 500, $e->getMessage());
}
}
public function getAnakBelumDisetujui()
{
try {
$user = User::getUser(Auth::user());
if (!$user) {
return $this->errorResponse("User tidak ditemukan", 401);
}
$anak = Anak::where('status', false)
->where('id_posyandu', $user->id_posyandu)
->with(['orangTua', 'posyandu', 'desa'])
->get();
if ($anak->isEmpty()) {
return $this->successResponse("Tidak ada anak yang belum disetujui.", []);
}
return $this->successResponse("Daftar anak yang belum disetujui", $anak);
} catch (\Exception $e) {
return $this->errorResponse("Gagal mengambil data anak", 500, $e->getMessage());
}
}
}
@@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
class ApiBaseController extends Controller
{
public function successResponse($message, $data = [])
{
$response = [
"code" => 200,
"message" => $message,
"data" => $data
];
return response()->json($response, 200);
}
public function errorValidationResponse($error, $errorMessages = [])
{
$code = 400;
$response = [
"code" => $code,
'message' => $error,
];
if (!empty($errorMessages)) {
$response['data'] = $errorMessages;
}
return response()->json($response, $code);
}
public function errorUnauthorizedResponse($error, $errorMessages = [])
{
$code = 401;
$response = [
"code" => $code,
'message' => $error,
];
if (!empty($errorMessages)) {
$response['data'] = $errorMessages;
}
return response()->json($response, $code);
}
public function errorNotFound($error, $errorMessages = [])
{
$code = 404;
$response = [
"code" => $code,
'message' => $error,
];
if (!empty($errorMessages)) {
$response['data'] = $errorMessages;
}
return response()->json($response, $code);
}
}
@@ -0,0 +1,116 @@
<?php
namespace App\Http\Controllers\Api;
use App\Models\Artikel;
use App\Models\Post;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ArtikelController extends ApiBaseController
{
public function index()
{
$response = Artikel::all();
return $this->successResponse("Data Artikel", $response);
}
public function store(Request $request)
{
$validator = validator($request->all(), [
'judul' => ['required'],
'kategori' => ['required'],
'penulis' => ['required'],
'content' => ['required'],
'image' => ['file', 'mimes:jpeg,png,jpg,gif,svg']
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Inputan Tidak Sesuai", $validator->errors());
}
$imageName = time() . '.' . $request->image->extension();
$request->image->move('img', $imageName);
$artikel = Artikel::create([
'judul' => $request->judul,
'kategori' => $request->kategori,
'image' => $imageName,
'penulis' => $request->penulis,
'content' => $request->content,
]);
$artikel->save();
return $this->successResponse("Data Berhasil Disimpan");
}
public function show($id)
{
$artikel = Artikel::findOrFail($id);
if (empty($artikel)) {
return $this->errorNotFound("Data Artikel tidak ditemukan");
}
return $this->successResponse("Data Artikel", $artikel);
}
public function update(Request $request, $id)
{
$artikel = Artikel::find($id);
if (empty($artikel)) {
return $this->errorNotFound("Data Artikel tidak ditemukan");
}
$validator = validator($request->all(), [
'judul' => ['required'],
'kategori' => ['required'],
'penulis' => ['required'],
'content' => ['required'],
'image' => ['file', 'mimes:jpeg,png,jpg,gif,svg']
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Inputan Tidak Sesuai", $validator->errors());
}
if ($request->hasFile('image')) {
$imageName = time() . '.' . $request->image->extension();
$request->image->move(public_path('img'), $imageName);
$artikel->image = $imageName;
}
$artikel->judul = $request->judul;
$artikel->kategori = $request->kategori;
$artikel->penulis = $request->penulis;
$artikel->content = $request->content;
$artikel->save();
return $this->successResponse("Success Update Data Artikel", $artikel);
}
public function destroy($id)
{
$artikel = Artikel::find($id);
if (empty($artikel)) {
return $this->errorNotFound("Data Artikel tidak ditemukan");
}
$artikel->delete();
return $this->successResponse("Success Delete Data Artikel");
}
public function getImage($id)
{
$artikel = Artikel::find($id);
if (empty($artikel)) {
return $this->errorNotFound("Data Artikel tidak ditemukan");
}
$imageUrl = asset('img/' . $artikel->image);
return $this->successResponse('image_url', $imageUrl);
}
}
@@ -0,0 +1,198 @@
<?php
namespace App\Http\Controllers\Api\Auth;
use App\Http\Controllers\Api\ApiBaseController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
class AuthenticateUserController extends ApiBaseController
{
/**
* Handle an incoming registration request.
*
* @param \Illuminate\Http\Request $request
* @param String $role
* @return \Illuminate\Http\JsonResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
private function login(Request $request, $role)
{
$validator = Validator::make($request->all(), [
'email' => ['required', 'string', 'email', 'max:255'],
'password' => ['required'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("gagal login", $validator->errors());
}
if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
$user = Auth::user();
$data = [
'token' => [
'type' => "Bearer",
'value' => $user->createToken('API Token')->plainTextToken,
],
'user' => [
'id' => $user->id,
'name' => $user->nama,
'email' => $user->email,
'id_desa' => $user->desa ? $user->desa->id : null,
'desa_name' => $user->desa ? $user->desa->name : null,
'id_posyandu' => $user->posyandu ? $user->posyandu->id : null,
'posyandu_name' => $user->posyandu ? $user->posyandu->nama : null,
'role' => $user->role->role,
'status' => $user->status // Fixed typo: $seur to $user
],
];
if ($user->role->role != $role) {
return $this->errorValidationResponse("periksa kembali email dan password");
}
return $this->successResponse("berhasil login", $data);
}
return $this->errorValidationResponse("periksa kembali email dan password");
}
public function loginbaru(Request $request)
{
$validator = Validator::make($request->all(), [
'email' => ['required', 'string', 'email', 'max:255'],
'password' => ['required'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("gagal login", $validator->errors());
}
if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
$user = Auth::user();
$data = [
'token' => [
'type' => "Bearer",
'value' => $user->createToken('API Token')->plainTextToken,
],
'user' => [
'id' => $user->id,
'name' => $user->nama,
'email' => $user->email,
'id_desa' => $user->desa ? $user->desa->id : null,
'desa_name' => $user->desa ? $user->desa->name : null,
'id_posyandu' => $user->posyandu ? $user->posyandu->id : null,
'posyandu_name' => $user->posyandu ? $user->posyandu->nama : null,
'role' => $user->role->role,
'status' => $user->status
],
];
return $this->successResponse("berhasil login", $data);
}
return $this->errorValidationResponse("periksa kembali email dan password");
}
public function loginOrangTua(Request $request)
{
return $this->login($request, "ORANG_TUA");
}
public function loginKaderPosyandu(Request $request)
{
return $this->login($request, "KADER_POSYANDU");
}
public function loginDesa(Request $request)
{
return $this->login($request, "DESA");
}
public function loginTenagaKesehatan(Request $request)
{
return $this->login($request, "TENAGA_KESEHATAN");
}
public function loginAdmin(Request $request)
{
return $this->login($request, "ADMIN");
}
/**
* Update the authenticated user's profile.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function updateProfile(Request $request)
{
$user = Auth::user();
if (!$user) {
return $this->errorUnauthorizedResponse("Unauthenticated");
}
$validator = Validator::make($request->all(), [
'nama' => ['required', 'string', 'max:255'], // Added validation for nama
'password' => ['nullable', 'string', 'min:8', 'confirmed'],
'password_confirmation' => ['nullable', 'required_with:password', 'same:password'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Gagal memperbarui profil", $validator->errors());
}
try {
$user->nama = $request->nama;
// Update password only if provided
if ($request->filled('password')) {
$user->password = Hash::make($request->password);
}
$user->save();
$data = [
'user' => [
'id' => $user->id,
'name' => $user->nama,
'email' => $user->email,
'id_desa' => $user->desa ? $user->desa->id : null, // Fixed potential null reference
'id_posyandu' => $user->posyandu ? $user->posyandu->id : null, // Fixed potential null reference
'role' => $user->role->role
],
];
return $this->successResponse("Profil berhasil diperbarui", $data);
} catch (\Exception $e) {
\Log::error("Error updating profile: " . $e->getMessage());
return $this->errorValidationResponse("Gagal memperbarui profil", [$e->getMessage()]);
}
}
public function getProfile()
{
$user = Auth::user();
if (!$user) {
return $this->errorUnauthorizedResponse("Unauthenticated");
}
try {
$data = [
'user' => [
'name' => $user->nama,
],
];
return $this->successResponse("Profil berhasil diambil", $data);
} catch (\Exception $e) {
\Log::error("Error fetching profile: " . $e->getMessage());
return $this->errorValidationResponse("Gagal mengambil profil", [$e->getMessage()]);
}
}
}
@@ -0,0 +1,195 @@
<?php
namespace App\Http\Controllers\Api\Auth;
use App\Http\Controllers\Api\ApiBaseController;
use App\Models\User;
use App\Models\Role;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class RegisterUserController extends ApiBaseController
{
/**
* Handle an incoming registration request.
*
* @param \Illuminate\Http\Request $request
* @param String $role
* @return \Illuminate\Http\JsonResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
private function register(Request $request, $role)
{
$rules = [
'nama' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:6'],
'alamat' => ['sometimes', 'string', 'max:255'],
'id_desa' => ['required', 'exists:data_desa,id'],
'status' => ['nullable', 'boolean'],
];
// Make id_posyandu optional for TENAGA_KESEHATAN
if ($role !== 'TENAGA_KESEHATAN') {
$rules['id_posyandu'] = ['required', 'exists:data_posyandu,id'];
} else {
$rules['id_posyandu'] = ['nullable', 'exists:data_posyandu,id'];
}
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return $this->errorValidationResponse("gagal registrasi", $validator->errors());
}
$roleModel = Role::where('role', $role)->first();
if (!$roleModel) {
return $this->errorValidationResponse("Role tidak ditemukan");
}
try {
$user = User::create([
'nama' => $request->nama,
'email' => $request->email,
'password' => Hash::make($request->password),
'alamat' => $request->alamat ?? null,
'id_desa' => $request->id_desa,
'id_posyandu' => $request->id_posyandu,
'status' => $request->has('status') ? $request->status : 0,
]);
$user->role()->associate($roleModel);
$user->push();
return $this->successResponse("registrasi berhasil, silahkan log in");
} catch (\Exception $e) {
\Log::error("Error registering user: " . $e->getMessage());
return $this->errorResponse("Gagal registrasi", [$e->getMessage()], 500);
}
}
/**
* Update an existing user.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\JsonResponse
*/
public function updateUser(Request $request, $id)
{
$user = User::find($id);
if (!$user) {
return $this->errorResponse("User tidak ditemukan", [], 404);
}
$rules = [
'nama' => ['sometimes', 'string', 'max:255'],
'email' => ['sometimes', 'string', 'email', 'max:255', 'unique:users,email,' . $id],
'password' => ['sometimes', 'string', 'min:6'],
'alamat' => ['sometimes', 'string', 'max:255'],
'id_desa' => ['sometimes', 'exists:data_desa,id'],
'status' => ['sometimes', 'boolean'],
];
// Make id_posyandu optional for TENAGA_KESEHATAN during update
if ($user->role->role !== 'TENAGA_KESEHATAN') {
$rules['id_posyandu'] = ['sometimes', 'required', 'exists:data_posyandu,id'];
} else {
$rules['id_posyandu'] = ['sometimes', 'nullable', 'exists:data_posyandu,id'];
}
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return $this->errorValidationResponse("Gagal memperbarui user", $validator->errors());
}
try {
// Update user fields
$updateData = [];
if ($request->has('nama')) {
$updateData['nama'] = $request->nama;
}
if ($request->has('email')) {
$updateData['email'] = $request->email;
}
if ($request->has('password')) {
$updateData['password'] = Hash::make($request->password);
}
if ($request->has('alamat')) {
$updateData['alamat'] = $request->alamat;
}
if ($request->has('id_desa')) {
$updateData['id_desa'] = $request->id_desa;
}
if ($request->has('id_posyandu')) {
$updateData['id_posyandu'] = $request->id_posyandu;
} elseif ($request->has('id_posyandu') && $request->id_posyandu === null && $user->role->role === 'TENAGA_KESEHATAN') {
$updateData['id_posyandu'] = null;
}
if ($request->has('status')) {
$updateData['status'] = $request->status;
}
$user->update($updateData);
return $this->successResponse("User berhasil diperbarui");
} catch (\Exception $e) {
\Log::error("Error updating user: " . $e->getMessage());
return $this->errorResponse("Gagal memperbarui user", [$e->getMessage()], 500);
}
}
/**
* Soft delete a user.
*
* @param int $id
* @return \Illuminate\Http\JsonResponse
*/
public function deleteUser($id)
{
$user = User::find($id);
if (!$user) {
return $this->errorResponse("User tidak ditemukan", [], 404);
}
try {
$user->delete();
return $this->successResponse("User berhasil dihapus");
} catch (\Exception $e) {
\Log::error("Error deleting user: " . $e->getMessage());
return $this->errorResponse("Gagal menghapus user", [$e->getMessage()], 500);
}
}
public function registerOrangTua(Request $request)
{
return $this->register($request, "ORANG_TUA");
}
public function registerKaderPosyandu(Request $request)
{
return $this->register($request, "KADER_POSYANDU");
}
public function registerDesa(Request $request)
{
return $this->register($request, "DESA");
}
public function registerTenagaKesehatan(Request $request)
{
return $this->register($request, "TENAGA_KESEHATAN");
}
public function registerAdmin(Request $request)
{
return $this->register($request, "ADMIN");
}
}
@@ -0,0 +1,124 @@
<?php
namespace App\Http\Controllers\Api;
use App\Models\Comment;
use App\Models\Post;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class CommentController extends ApiBaseController
{
public function index()
{
$comment = Comment::with('user')->with('post')->get();
$response = [];
foreach ($comment as $key => $data) {
$response[$key] = [
"comment_id" => $data->id,
"post_id" => $data->post_id,
"title_post" => $data->post->title,
"content" => $data->post->content,
"user_id" => $data->user_id,
"nama" => $data->user->nama,
"role" => $data->role->role,
"email" => $data->user->email,
"comment" => $data->content,
"time" => Carbon::createFromFormat('Y-m-d H:i:s', $data->created_at)->format('Y-m-d H:i:s'),
];
}
return $this->successResponse("Data Post", $response);
}
public function store(Request $request)
{
$validator = validator($request->all(), [
'user_id' => ['required', 'integer'],
'post_id' => ['required', 'integer'],
'content' => ['required', 'string'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Inputan Tidak Sesuai", $validator->errors());
}
$user = User::find($request->user_id);
if (!$user) {
return $this->errorNotFound("User Tidak Ditemukan");
}
$post = Post::find($request->post_id);
if (!$post) {
return $this->errorNotFound("Post Tidak Ditemukan");
}
$comment = new Comment();
$comment->fill([
'user_id' => $request->user_id,
'post_id' => $request->post_id,
'content' => $request->content,
]);
// Jika role user adalah TENAGA_KESEHATAN, tandai post sebagai telah dibaca
if ($user->role->role === 'TENAGA_KESEHATAN') {
$post->read = true;
$post->save();
}
$comment->save();
return $this->successResponse("Data Berhasil Disimpan");
}
public function show($id)
{
$comment = Post::find($id)->comments->all();
if (empty($comment)) {
return $this->errorNotFound("Data Post tidak ditemukan");
}
$response = [];
foreach ($comment as $key => $data) {
$user = User::find($data->user_id);
$response[$key] = [
"user_id" => $user->id,
"nama" => $user->nama,
"role" => $user->role->role,
"email" => $user->email,
"comment_id" => $data->id,
"content" => $data->content,
"time" => Carbon::createFromFormat('Y-m-d H:i:s', $data->created_at)->format('Y-m-d H:i:s'),
];
}
return $this->successResponse("Data Comment", $response);
}
public function update(Request $request, $id)
{
//
}
public function destroy($id)
{
$comment = Comment::findOrFail($id);
if (empty($comment)) {
return $this->errorNotFound("Data Comment tidak ditemukan");
}
$comment->delete();
return $this->successResponse("Success Delete Data Post");
}
}
+253
View File
@@ -0,0 +1,253 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Resources\DesaResource;
use App\Models\Desa;
use App\Models\User;
use App\Models\Role;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Validator;
class DesaController extends ApiBaseController
{
/**
* Display a listing of the resource.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function index()
{
$desa = Desa::all();
return $this->successResponse("data desa", $desa);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// Validasi input untuk desa dan akun
$validator = Validator::make($request->all(), [
'name' => ['required', 'string', 'max:255'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Gagal input data desa atau akun", $validator->errors());
}
// Normalisasi nama untuk email (huruf kecil, tanpa spasi)
$namaDesa = $request->name;
$email = Str::slug($namaDesa, '') . '@gmail.com';
// Validasi email unik
$emailValidator = Validator::make(['email' => $email], [
'email' => ['required', 'email', 'unique:users,email'],
]);
if ($emailValidator->fails()) {
return $this->errorValidationResponse("Email {$email} sudah digunakan", $emailValidator->errors());
}
// Mulai transaksi database
DB::beginTransaction();
try {
// Buat data desa
$desa = Desa::create([
'name' => $namaDesa,
]);
if (!$desa) {
throw new \Exception("Gagal menyimpan data desa");
}
// Cari role DESA
$role = Role::where('role', 'DESA')->first();
if (!$role) {
throw new \Exception("Role DESA tidak ditemukan");
}
// Buat akun dengan role DESA
$user = User::create([
'nama' => $namaDesa,
'email' => $email,
'password' => bcrypt($request->password),
'id_desa' => $desa->id,
'status' => true,
]);
// Kaitkan role DESA
$user->role()->associate($role);
$user->save();
// Commit transaksi
DB::commit();
// Kembalikan respons sukses dengan data
return $this->successResponse("Data desa dan akun berhasil dibuat", [
'desa' => new DesaResource($desa),
'user' => [
'email' => $email,
'role' => 'DESA',
'status' => true,
],
]);
} catch (\Exception $e) {
// Rollback transaksi jika gagal
DB::rollBack();
return $this->errorValidationResponse("Gagal membuat data desa dan akun: " . $e->getMessage());
}
}
/**
* Display the specified resource.
*
* @param \App\Models\Desa $desa
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Desa $desa
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Desa $desa
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$desa = Desa::withCount(['posyandu', 'anak'])->find($id);
if (!$desa) {
return $this->errorNotFound("Desa tidak ditemukan");
}
if ($desa->posyandu_count > 0 || $desa->anak_count > 0) {
return $this->errorValidationResponse("Tidak bisa menghapus desa karena memiliki data posyandu atau anak yang terkait.");
}
$desa->delete();
return $this->successResponse("Desa berhasil dihapus");
}
public function getStatistikDesa($id)
{
$desa = Desa::find($id);
if (empty($desa)) {
return $this->errorNotFound("Desa tidak ditemukan");
}
$response = [];
$all_posyandu = $desa->posyandu;
// Inisialisasi total
$total = [
"id_posyandu" => null,
"nama_posyandu" => "Total Semua Posyandu",
"jumlah_anak" => 0,
"berat_badan" => [
'gemuk' => 0,
'normal' => 0,
'kurus' => 0,
'sangat_kurus' => 0,
],
"tinggi_badan" => [
'tinggi' => 0,
'normal' => 0,
'pendek' => 0,
'sangat_pendek' => 0,
],
"lingkar_kepala" => [
'makrosefali' => 0,
'normal' => 0,
'mikrosefali' => 0,
],
];
foreach ($all_posyandu as $key => $posyandu) {
$statistik = [
"id_posyandu" => $posyandu->id,
"nama_posyandu" => $posyandu->nama,
"jumlah_anak" => 0,
"berat_badan" => [
'gemuk' => 0,
'normal' => 0,
'kurus' => 0,
'sangat_kurus' => 0,
],
"tinggi_badan" => [
'tinggi' => 0,
'normal' => 0,
'pendek' => 0,
'sangat_pendek' => 0,
],
"lingkar_kepala" => [
'makrosefali' => 0,
'normal' => 0,
'mikrosefali' => 0,
],
];
if (!empty($posyandu->anak)) {
$allLatsStatistik = [];
foreach ($posyandu->anak as $anak) {
$latestStatistik = DB::table('data_statistik_anak')->where('id_anak', $anak->id)->latest('created_at')->first();
if ($latestStatistik) {
$allLatsStatistik[] = $latestStatistik;
}
}
$statistik["jumlah_anak"] = $posyandu->jumlahAnak();
$statistik["berat_badan"] = $posyandu->laporanBerat($allLatsStatistik);
$statistik["tinggi_badan"] = $posyandu->laporanTinggi($allLatsStatistik);
$statistik["lingkar_kepala"] = $posyandu->laporanLingkarKepala($allLatsStatistik);
// Tambahkan ke total
$total["jumlah_anak"] += $statistik["jumlah_anak"];
foreach ($statistik["berat_badan"] as $keyBB => $val) {
$total["berat_badan"][$keyBB] += $val;
}
foreach ($statistik["tinggi_badan"] as $keyTB => $val) {
$total["tinggi_badan"][$keyTB] += $val;
}
foreach ($statistik["lingkar_kepala"] as $keyLK => $val) {
$total["lingkar_kepala"][$keyLK] += $val;
}
}
$response[] = $statistik;
}
// Sisipkan total di paling atas
array_unshift($response, $total);
return $this->successResponse("Data Statistik Desa", $response);
}
}
@@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
class HitungZScoreController
{
public function HitungZScoreBerat(int $berat): array
{
$z_score_berat = $berat / 20;
if ($z_score_berat <= -3) {
$status_berat_badan = 'Sangat Kurus';
} else if ($z_score_berat > -3 && $z_score_berat <= -2) {
$status_berat_badan = 'Kurus';
} else if ($z_score_berat > -2 && $z_score_berat <= 2) {
$status_berat_badan = 'Normal';
} else if ($z_score_berat > 2) {
$status_berat_badan = 'Gemuk';
}
return [
'z_score_berat' => $z_score_berat,
'status_berat_badan'=> $status_berat_badan
];
}
public function HitungZScoreTinggi(int $tinggi): array
{
$z_score_tinggi = $tinggi / 20;
if ($z_score_tinggi <= -3) {
$status_tinggi_badan = 'Sangat Pendek';
} else if ($z_score_tinggi > -3 && $z_score_tinggi <= -2) {
$status_tinggi_badan = 'Pendek';
} else if ($z_score_tinggi > -2 && $z_score_tinggi <= 3) {
$status_tinggi_badan = 'Normal';
} else if ($z_score_tinggi > 3) {
$status_tinggi_badan = 'Tinggi';
}
return [
'z_score_tinggi' => $z_score_tinggi,
'status_tinggi_badan'=> $status_tinggi_badan
];
}
public function HitungZScoreLiLA(int $LiLA): array
{
$z_score_lingkar_kepala = $LiLA / 20;
if ($z_score_lingkar_kepala > 2) {
$status_lingkar_kepala = 'Makrosefali';
} else if ($z_score_lingkar_kepala > -2 && $z_score_lingkar_kepala <= 2) {
$status_lingkar_kepala = 'Normal';
} else if ($z_score_lingkar_kepala < -2) {
$status_lingkar_kepala = 'Mikrosefali';
}
return [
'z_score_lingkar_kepala' => $z_score_lingkar_kepala,
'status_lingkar_kepala'=> $status_lingkar_kepala
];
}
}
@@ -0,0 +1,91 @@
<?php
namespace App\Http\Controllers\api;
use App\Models\Kategori;
use Illuminate\Http\Request;
class KategoriController extends ApiBaseController
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$response = Kategori::all();
return $this->successResponse("Data Artikel", $response);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = validator($request->all(), [
'name' => ['required']
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Inputan Tidak Sesuai", $validator->errors());
}
$kategori = Kategori::create([
'name' => $request->name,
]);
$kategori->save();
return $this->successResponse("Data Berhasil Disimpan");
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$kategori = Kategori::findOrFail($id);
$kategori->fill($request->all());
$kategori->save();
return $this->successResponse("Success Update Data", $kategori);
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$kategori = Kategori::find($id);
if (empty($kategori)) {
return $this->errorNotFound("Data tidak ditemukan");
}
$kategori->delete();
return $this->successResponse("Success Delete Data");
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\Api;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class OrangTuaController extends ApiBaseController
{
public function index()
{
$user = Auth::user();
$orangtua = User::where('id_role', 3)
->where('id_desa', $user->id_desa)
->where('id_posyandu', $user->id_posyandu)
->where('status', 1) // Filter only approved parents
->get();
return $this->successResponse("data orang tua", $orangtua);
}
}
+233
View File
@@ -0,0 +1,233 @@
<?php
namespace App\Http\Controllers\Api;
use App\Models\Post;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PostController extends ApiBaseController
{
public function index()
{
$post = Post::with('user')->get();
$response = [];
foreach ($post as $key => $data) {
$response[$key] = [
"post_id" => $data->id,
"user_id" => $data->user->id,
"nama" => $data->user->nama,
"role" => $data->user->role->role,
"title" => $data->title,
"content" => $data->content,
"read"=> $data->read,
"time" => Carbon::createFromFormat('Y-m-d H:i:s', $data->created_at)->format('Y-m-d H:i:s'),
];
}
return $this->successResponse("Data Post", $response);
}
public function store(Request $request)
{
$validator = validator($request->all(), [
'user_id' => ['required', 'integer'],
'title' => ['required', 'string'],
'content' => ['string'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Input Masih Tidak Sesuai", $validator->errors());
}
$user = DB::table('users')->where('id', $request->user_id)->get();
if ($user->isEmpty()) {
return $this->errorNotFound("User Tidak Ditemukan");
} else if (!$user->where('id_role', 3)->first()) {
return $this->errorUnauthorizedResponse("User Tidak Memiliki Hak Akses");
}
$post = new Post();
$post->fill([
'user_id' => $request->user_id,
'title' => $request->title,
'content' => $request->content,
'read' => 0, // Set a default value for the 'read' column (e.g., 0 for unread)
]);
$post->save();
return $this->successResponse("Data Post Berhasil Disimpan");
}
public function showByOrangTua($id)
{
$posts = Post::with('user')->where('user_id', $id)->get();
if ($posts->isEmpty()) {
return $this->errorNotFound("Data Orang Tua tidak ditemukan");
}
$response = [];
foreach ($posts as $key => $data) {
$response[$key] = [
"post_id" => $data->id,
"user_id" => $data->user->id,
"nama" => $data->user->nama,
"role" => $data->user->role->role,
"title" => $data->title,
"content" => $data->content,
"read"=> $data->read,
"time" => Carbon::createFromFormat('Y-m-d H:i:s', $data->created_at)->format('Y-m-d H:i:s'),
];
}
return $this->successResponse("Data Post", $response);
}
public function showByTenagaKesehatan($id)
{
$user = User::find($id);
if (!$user || !$user->id_desa) {
return $this->errorNotFound("Data Pengguna atau Desa tidak ditemukan");
}
$tenagaKesehatanUsers = User::where('id_desa', $user->id_desa)
->whereHas('role', function ($query) {
$query->where('role', 'ORANG_TUA');
})
->pluck('id');
$posts = Post::with(['user.role', 'user.posyandu', 'comments.user.role'])
->whereIn('user_id', $tenagaKesehatanUsers)
->get();
if ($posts->isEmpty()) {
return $this->errorNotFound("Data Post dari Tenaga Kesehatan tidak ditemukan");
}
$response = [];
foreach ($posts as $key => $data) {
$commentsFromTenagaKesehatan = [];
foreach ($data->comments as $comment) {
if ($comment->user && $comment->user->role && $comment->user->role->role === 'TENAGA_KESEHATAN') {
$commentsFromTenagaKesehatan[] = [
'comment_id' => $comment->id,
'user_id' => $comment->user->id,
'nama' => $comment->user->nama,
'role' => $comment->user->role->role,
'content' => $comment->content,
'time' => Carbon::parse($comment->created_at)->format('Y-m-d H:i:s'),
];
}
}
$response[$key] = [
"post_id" => $data->id,
"user_id" => $data->user->id ?? null,
"nama" => $data->user->nama ?? "-",
"role" => $data->user->role->role ?? "-",
"posyandu" => $data->user->posyandu->nama ?? "-",
"title" => $data->title,
"content" => $data->content,
"read" => $data->read,
"time" => Carbon::parse($data->created_at)->format('Y-m-d H:i:s'),
"jawaban_tenaga_kesehatan" => $commentsFromTenagaKesehatan, // hanya komentar dari tenaga kesehatan
];
}
return $this->successResponse("Data Post Tenaga Kesehatan", $response);
}
public function show($id)
{
$post = Post::find($id);
if (empty($post)) {
return $this->errorNotFound("Data Post tidak ditemukan");
}
$user = User::find($post->user_id);
$response = [
"user_id" => $user->id,
"nama" => $user->nama,
"role" => $user->role->role,
"title" => $post->title,
"content" => $post->content,
"time" => Carbon::createFromFormat('Y-m-d H:i:s', $post->created_at)->format('Y-m-d H:i:s')
];
return $this->successResponse("Data Post", $response);
}
public function update(Request $request, $id)
{
$post = Post::findOrFail($id);
if (empty($post)) {
return $this->errorNotFound("Data Post tidak ditemukan");
}
$validator = validator($request->all(), [
'user_id' => ['required', 'integer'],
'title' => ['required', 'string'],
'content' => ['string'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Input Masih Tidak Sesuai", $validator->errors());
}
if (User::where('id', $request->user_id)->doesntExist()) {
return $this->errorNotFound("User Tidak Ditemukan");
}
$post->fill([
'user_id' => $request->user_id,
'title' => $request->title,
'content' => $request->content,
]);
$post->save();
return $this->successResponse("Success Update Data Post");
}
public function destroy($id)
{
$post = Post::findOrFail($id);
if (empty($post)) {
return $this->errorNotFound("Data Post tidak ditemukan");
}
$post->delete();
return $this->successResponse("Success Delete Data Post");
}
public function changeobesitas(){
$obe = DB::table('data_statistik_anak')->where('status_berat_badan', 'Obesitas')->update(array('status_berat_badan' => 'Gemuk'));
return $this->successResponse("Success Data");
}
public function changestatusLK(){
$LK1 = DB::table('data_statistik_anak')->where('status_lingkar_kepala', 'Makrosefalus')->update(array('status_lingkar_kepala' => 'Makrosefali'));
$LK2 = DB::table('data_statistik_anak')->where('status_lingkar_kepala', 'Microcephaly')->update(array('status_lingkar_kepala' => 'Mikrosefali'));
return $this->successResponse("Success Data");
}
}
@@ -0,0 +1,151 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Models\Posyandu;
use App\Models\User;
class PosyanduController extends ApiBaseController
{
public function index(Request $request)
{
$posyandu = Posyandu::all();
return $this->successResponse("data posyandu", $posyandu);
}
public function store(Request $request)
{
$validator = validator($request->all(), [
'id_desa' => ['exists:data_desa,id', 'required'],
'nama' => ['string', 'required'],
'alamat' => ['string', 'required'],
'latitude' => ['string'],
'longitude' => ['string'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("gagal input data posyandu", $validator->errors());
}
$posyandu = Posyandu::make([
'nama' => $request->nama,
'alamat' => $request->alamat,
'latitude' => $request->latitude,
'longitude' => $request->longitude,
]);
$posyandu->desa()->associate($request->id_desa);
if (!($posyandu->save())) {
return $this->errorValidationResponse("gagal create data Posyandu");
}
return $this->successResponse("success");
}
public function show($id)
{
//
}
public function update(Request $request, $id)
{
//
}
public function showKaderPosyandu()
{
try {
$kaderPosyandu = User::whereHas('role', function ($query) {
$query->where('role', 'KADER_POSYANDU');
})->with(['role', 'desa', 'posyandu'])->get();
if ($kaderPosyandu->isEmpty()) {
return $this->successResponse("Tidak ada Kader Posyandu yang terdaftar", []);
}
return $this->successResponse("Daftar Kader Posyandu", $kaderPosyandu);
} catch (\Exception $e) {
return $this->errorResponse("Gagal mengambil data Kader Posyandu: " . $e->getMessage(), 500);
}
}
public function showTenagaKesehatan()
{
try {
$tenagaKesehatan = User::whereHas('role', function ($query) {
$query->where('role', 'TENAGA_KESEHATAN');
})->with(['role', 'desa', 'posyandu'])->get();
if ($tenagaKesehatan->isEmpty()) {
return $this->successResponse("Tidak ada Tenaga Kesehatan yang terdaftar", []);
}
return $this->successResponse("Daftar Tenaga Kesehatan", $tenagaKesehatan);
} catch (\Exception $e) {
return $this->errorResponse("Gagal mengambil data Tenaga Kesehatan: " . $e->getMessage(), 500);
}
}
public function destroy($id)
{
try {
$posyandu = Posyandu::withCount('anak')->find($id);
if (!$posyandu) {
return $this->errorNotFound("Posyandu tidak ditemukan");
}
if ($posyandu->anak_count > 0) {
return $this->errorValidationResponse("Tidak bisa menghapus posyandu karena masih memiliki data anak.");
}
$posyandu->delete();
return $this->successResponse("Posyandu berhasil dihapus");
} catch (\Exception $e) {
return $this->errorValidationResponse("Gagal menghapus Posyandu", $e->getMessage());
}
}
public function deleteKaderPosyandu($userId)
{
try {
$user = User::whereHas('role', function ($query) {
$query->where('role', 'KADER_POSYANDU');
})->find($userId);
if (!$user) {
return $this->errorNotFound("Kader Posyandu tidak ditemukan");
}
$user->delete();
return $this->successResponse("Success Delete Kader Posyandu");
} catch (\Exception $e) {
return $this->errorResponse("Gagal menghapus Kader Posyandu: " . $e->getMessage(), 500);
}
}
public function deleteTenagaKesehatan($userId)
{
try {
$user = User::whereHas('role', function ($query) {
$query->where('role', 'TENAGA_KESEHATAN');
})->find($userId);
if (!$user) {
return $this->errorNotFound("Tenaga Kesehatan tidak ditemukan");
}
$user->delete();
return $this->successResponse("Success Delete Tenaga Kesehatan");
} catch (\Exception $e) {
return $this->errorResponse("Gagal menghapus Tenaga Kesehatan: " . $e->getMessage(), 500);
}
}
}
@@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers\Api;
use App\Models\Reminder;
use App\Models\Post;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class ReminderController extends ApiBaseController
{
public function index()
{
$response = Reminder::all();
return $this->successResponse("Data Reminder", $response);
}
public function store(Request $request)
{
$user = Auth::user();
$validator = validator($request->all(), [
'judul' => ['required', 'string'],
'deskripsi' => ['required', 'string'],
'tanggal_reminder' => ['required', 'date'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("Inputan Tidak Sesuai", $validator->errors());
}
$reminder = Reminder::create([
'judul' => $request->judul,
'deskripsi' => $request->deskripsi,
'tanggal_reminder' => $request->tanggal_reminder,
'id_desa' => $user->id_desa,
]);
$reminder->save();
return $this->successResponse("Reminder telah di set");
}
public function show()
{
$user = Auth::user();
$tanggalSekarang = Carbon::now()->toDateString(); //untuk tanggal
// $tanggalSekarang = Carbon::now()->format('Y-m-d'); //untuk bulan
$reminder = Reminder::where('id_desa', $user->id_desa)->whereDate('tanggal_reminder', '>=', $tanggalSekarang)->orderBy('tanggal_reminder', 'asc')->get();
return $this->successResponse("Data Reminder", $reminder);
}
public function update(Request $request, $id)
{
$reminder = Reminder::find($id);
if (empty($reminder)) {
return $this->errorNotFound("Data Reminder tidak ditemukan");
}
$reminder->fill($reminder->all());
$reminder->save();
return $this->successResponse("Success Update Data Reminder", $reminder);
}
public function destroy($id)
{
$reminder = Reminder::find($id);
if (empty($reminder)) {
return $this->errorNotFound("Data Reminder tidak ditemukan");
}
$reminder->delete();
return $this->successResponse("Success Delete Data Reminder");
}
}
@@ -0,0 +1,310 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Resources\StatistikResource;
use App\Models\StatistikAnak;
use App\Models\Anak;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class StatistikAnakController extends ApiBaseController
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = validator($request->all(), [
'id_anak' => ['required', 'integer', 'exists:data_anak,id'],
'tinggi' => ['required'],
'berat' => ['required'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("gagal input data anak", $validator->errors());
}
$anak = Anak::find($request->id_anak);
if (empty($anak)) {
return $this->errorNotFound("Data Anak Tidak Ditemukan");
}
if ($request->z_score_berat <= -3) {
$status_berat_badan = 'Sangat Kurus';
} else if ($request->z_score_berat > -3 && $request->z_score_berat <= -2) {
$status_berat_badan = 'Kurus';
} else if ($request->z_score_berat > -2 && $request->z_score_berat <= 2) {
$status_berat_badan = 'Normal';
} else if ($request->z_score_berat > 2) {
$status_berat_badan = 'Gemuk';
}
if ($request->z_score_tinggi <= -3) {
$status_tinggi_badan = 'Sangat Pendek';
} else if ($request->z_score_tinggi > -3 && $request->z_score_tinggi <= -2) {
$status_tinggi_badan = 'Pendek';
} else if ($request->z_score_tinggi > -2 && $request->z_score_tinggi <= 3) {
$status_tinggi_badan = 'Normal';
} else if ($request->z_score_tinggi > 3) {
$status_tinggi_badan = 'Tinggi';
}
if ($request->z_score_lingkar_kepala > 2) {
$status_lingkar_kepala = 'Makrosefali';
} else if ($request->z_score_lingkar_kepala > -2 && $request->z_score_lingkar_kepala <= 2) {
$status_lingkar_kepala = 'Normal';
} else if ($request->z_score_lingkar_kepala < -2) {
$status_lingkar_kepala = 'Mikrosefali';
}
if ($request->z_score_gizi > 3) {
$gizi = 'Obesitas';
} elseif ($request->z_score_gizi > 2 && $request->z_score_gizi <= 3) {
$gizi = 'Gizi Lebih';
} elseif ($request->z_score_gizi > 1 && $request->z_score_gizi <= 2) {
$gizi = 'Beresiko Gizi Lebih';
} elseif ($request->z_score_gizi >= -2 && $request->z_score_gizi <= 1) {
$gizi = 'Gizi Baik';
} elseif ($request->z_score_gizi >= -3 && $request->z_score_gizi < -2) {
$gizi = 'Gizi Kurang';
} elseif ($request->z_score_gizi < -3) {
$gizi = 'Gizi Buruk';
}
$statistik = StatistikAnak::create([
'id_anak' => $request->id_anak,
'tinggi' => $request->tinggi,
'berat' => $request->berat,
'lingkar_kepala' => $request->lingkar_kepala,
'date' => $request->date,
'z_score_berat' => $request->z_score_berat,
'z_score_tinggi' => $request->z_score_tinggi,
'z_score_lingkar_kepala' => $request->z_score_lingkar_kepala,
'status_berat_badan' => $status_berat_badan,
'status_tinggi_badan' => $status_tinggi_badan,
'status_lingkar_kepala' => $status_lingkar_kepala,
'z_score_gizi' => $request->z_score_gizi,
'status_gizi' => $gizi,
]);
$statistik->save();
return $this->successResponse("Success");
}
public function show($id)
{
$anak = Anak::find($id);
if (empty($anak)) {
return $this->errorNotFound("Data Pekembangan Anak Tidak Ditemukan");
}
$statistik = $anak->statistik()->orderBy('date', 'desc')->get();
$response = StatistikResource::collection($statistik);
return $this->successResponse("list statistik anak", $response);
}
public function ShowAllByOrtu()
{
$user = Auth::user();
$anakId = Anak::where('id_orang_tua', $user->id)->pluck('id')->all();
$badan = [];
$tinggi = [];
$lingkaran = [];
$gizi = [];
$response = [];
$statisBeratBadan = 'Ideal';
$statisTinggiBadan = 'Ideal';
$statisLingkaranKepala = 'Ideal';
$statisGizi = 'Ideal';
foreach ($anakId as $id){
$anak = Anak::find($id);
if (empty($anak)) {
return $this->errorNotFound("Data Pekembangan Anak Tidak Ditemukan");
}
$statistik = $anak->statistik()->get();
$allStatik = StatistikResource::collection($statistik);
$statikSebelum = null;
foreach($allStatik as $rawStatik){
$json = json_encode($rawStatik); //ubah ke json
$statik = json_decode($json); //ubah ke php
if ($statik->statistik->berat != 'Normal'){
$statisBeratBadan = 'Tidak Ideal';
}
if ($statik->statistik->tinggi != 'Normal'){
$statisTinggiBadan = 'Tidak Ideal';
}
if ($statik->statistik->lingkar_kepala != 'Normal'){
$statisLingkaranKepala = 'Tidak Ideal';
}
if ($statik->statistik->gizi != 'Gizi Baik'){
$statisGizi = 'Tidak Ideal';
}
$statisTingkatBeratBadan = 'Tetap';
$statisTingkatTinggiBadan = 'Tetap';
$statisTingkatLingkaranKepala = 'Tetap';
$statisTingkatGizi = 'Tetap';
if ($statikSebelum !== null){
if ($statikSebelum->statistik->berat != 'Normal' && $statik->statistik->berat == 'Normal'){
$statisTingkatBeratBadan = 'Meningkat';
}
if ($statikSebelum->statistik->berat == 'Normal' && $statik->statistik->berat != 'Normal'){
$statisTingkatBeratBadan = 'Menurun';
}
if ($statikSebelum->statistik->tinggi != 'Normal' && $statik->statistik->tinggi == 'Normal'){
$statisTingkatTinggiBadan = 'Meningkat';
}
if ($statikSebelum->statistik->tinggi == 'Normal' && $statik->statistik->tinggi != 'Normal'){
$statisTingkatTinggiBadan = 'Menurun';
}
if ($statikSebelum->statistik->lingkar_kepala != 'Normal' && $statik->statistik->lingkar_kepala == 'Normal'){
$statisTingkatLingkaranKepala = 'Meningkat';
}
if ($statikSebelum->statistik->lingkar_kepala == 'Normal' && $statik->statistik->lingkar_kepala != 'Normal'){
$statisTingkatLingkaranKepala = 'Menurun';
}
if ($statikSebelum->statistik->gizi != 'Gizi Baik' && $statik->statistik->gizi == 'Gizi Baik'){
$statisTingkatGizi = 'Meningkat';
}
if ($statikSebelum->statistik->gizi == 'Gizi Baik' && $statik->statistik->gizi != 'Gizi Baik'){
$statisTingkatGizi = 'Menurun';
}
}
$statikSebelum = $statik;
}
$badan['nama_status'] = 'Statistik berat badan';
$badan['kondisi'] = $statisBeratBadan;
$badan['perkembangan'] = $statisTingkatBeratBadan;
$tinggi['nama_status'] = 'Statistik tinggi badan';
$tinggi['kondisi'] = $statisTinggiBadan;
$tinggi['perkembangan'] = $statisTingkatTinggiBadan;
$lingkaran['nama_status'] = 'Statistik lingkaran kepala';
$lingkaran['kondisi'] = $statisLingkaranKepala;
$lingkaran['perkembangan'] = $statisTingkatLingkaranKepala;
$gizi['nama_status'] = 'Statistik gizi';
$gizi['kondisi'] = $statisGizi;
$gizi['perkembangan'] = $statisTingkatGizi;
}
$response[] = $badan;
$response[] = $tinggi;
$response[] = $lingkaran;
$response[] = $gizi;
return $this->successResponse("list statistik anak", $response);
}
public function update(Request $request, $id)
{
$statistik = StatistikAnak::find($id);
if (!$statistik) {
return $this->errorNotFound("Data Perkembangan Anak Tidak Ditemukan");
}
if ($request->z_score_berat <= -3) {
$status_berat_badan = 'Sangat Kurus';
} else if ($request->z_score_berat > -3 && $request->z_score_berat <= -2) {
$status_berat_badan = 'Kurus';
} else if ($request->z_score_berat > -2 && $request->z_score_berat <= 2) {
$status_berat_badan = 'Normal';
} else if ($request->z_score_berat > 2) {
$status_berat_badan = 'Gemuk';
}
if ($request->z_score_tinggi <= -3) {
$status_tinggi_badan = 'Sangat Pendek';
} else if ($request->z_score_tinggi > -3 && $request->z_score_tinggi <= -2) {
$status_tinggi_badan = 'Pendek';
} else if ($request->z_score_tinggi > -2 && $request->z_score_tinggi <= 3) {
$status_tinggi_badan = 'Normal';
} else if ($request->z_score_tinggi > 3) {
$status_tinggi_badan = 'Tinggi';
}
if ($request->z_score_lingkar_kepala > 2) {
$status_lingkar_kepala = 'Makrosefali';
} else if ($request->z_score_lingkar_kepala > -2 && $request->z_score_lingkar_kepala <= 2) {
$status_lingkar_kepala = 'Normal';
} else if ($request->z_score_lingkar_kepala < -2) {
$status_lingkar_kepala = 'Mikrosefali';
}
if ($request->z_score_gizi > 3) {
$gizi = 'Obesitas';
} elseif ($request->z_score_gizi > 2 && $request->z_score_gizi <= 3) {
$gizi = 'Gizi Lebih';
} elseif ($request->z_score_gizi > 1 && $request->z_score_gizi <= 2) {
$gizi = 'Beresiko Gizi Lebih';
} elseif ($request->z_score_gizi >= -2 && $request->z_score_gizi <= 1) {
$gizi = 'Gizi Baik';
} elseif ($request->z_score_gizi >= -3 && $request->z_score_gizi < -2) {
$gizi = 'Gizi Kurang';
} elseif ($request->z_score_gizi < -3) {
$gizi = 'Gizi Buruk';
}
$statistik->tinggi = $request->tinggi;
$statistik->berat = $request->berat;
$statistik->lingkar_kepala = $request->lingkar_kepala;
$statistik->date = $request->date;
$statistik->z_score_berat = $request->z_score_berat;
$statistik->z_score_tinggi = $request->z_score_tinggi;
$statistik->z_score_lingkar_kepala = $request->z_score_lingkar_kepala;
$statistik->status_berat_badan = $status_berat_badan;
$statistik->status_tinggi_badan = $status_tinggi_badan;
$statistik->status_lingkar_kepala = $status_lingkar_kepala;
$statistik->z_score_gizi = $request->z_score_gizi;
$statistik->status_gizi = $gizi;
$statistik->save();
return $this->successResponse("Success Update Data Statistik");
}
public function destroy($id)
{
$anak = StatistikAnak::findOrFail($id);
if (!$anak->delete()) {
return $this->errorValidationResponse("Gagal Delete Data Perkembangan Anak");
}
return $this->successResponse("Success Delete Data Statistik");
}
}
@@ -0,0 +1,91 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use Exception;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
class UploadController extends ApiBaseController
{
/**
* Display a listing of the resource.
*
* @param String $fileName
* @return \Illuminate\Http\Response
*/
public function index($fileName)
{
if (!(Storage::exists('image/' . $fileName))) {
return $this->errorNotFound("image not found");
}
$image = Storage::get('image/' . $fileName);
$path = Storage::path('image/' . $fileName);
$mimeType = File::mimeType($path);
return response($image)->header('content-type', $mimeType);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = validator($request->all(), [
'file' => ['required', 'file', 'mimes:jpg,png'],
'note' => ['string'],
]);
if ($validator->fails()) {
return $this->errorValidationResponse("validation failed", $validator->errors());
}
try {
$path = $request->file('file')->store('image');
} catch (Exception $e) {
return $this->errorValidationResponse("store file error", $e);
}
$response = [
"image-path" => '/api/' . $path,
];
return $this->successResponse("file uploaded", $response);
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
@@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AuthenticatedSessionController extends Controller
{
/**
* Display the login view.
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('auth.login');
}
/**
* Handle an incoming authentication request.
*
* @param \App\Http\Requests\Auth\LoginRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(LoginRequest $request)
{
$request->authenticate();
$request->session()->regenerate();
return redirect()->intended(RouteServiceProvider::HOME);
}
/**
* Destroy an authenticated session.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(Request $request)
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
}
@@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
class ConfirmablePasswordController extends Controller
{
/**
* Show the confirm password view.
*
* @return \Illuminate\View\View
*/
public function show()
{
return view('auth.confirm-password');
}
/**
* Confirm the user's password.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function store(Request $request)
{
if (! Auth::guard('web')->validate([
'email' => $request->user()->email,
'password' => $request->password,
])) {
throw ValidationException::withMessages([
'password' => __('auth.password'),
]);
}
$request->session()->put('auth.password_confirmed_at', time());
return redirect()->intended(RouteServiceProvider::HOME);
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
class EmailVerificationNotificationController extends Controller
{
/**
* Send a new email verification notification.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(RouteServiceProvider::HOME);
}
$request->user()->sendEmailVerificationNotification();
return back()->with('status', 'verification-link-sent');
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
class EmailVerificationPromptController extends Controller
{
/**
* Display the email verification prompt.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function __invoke(Request $request)
{
return $request->user()->hasVerifiedEmail()
? redirect()->intended(RouteServiceProvider::HOME)
: view('auth.verify-email');
}
}
@@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
class NewPasswordController extends Controller
{
/**
* Display the password reset view.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function create(Request $request)
{
return view('auth.reset-password', ['request' => $request]);
}
/**
* Handle an incoming new password request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$request->validate([
'token' => ['required'],
'email' => ['required', 'email'],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);
// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response.
$status = Password::reset(
$request->only('email', 'password', 'password_confirmation', 'token'),
function ($user) use ($request) {
$user->forceFill([
'password' => Hash::make($request->password),
'remember_token' => Str::random(60),
])->save();
event(new PasswordReset($user));
}
);
// If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.
return $status == Password::PASSWORD_RESET
? redirect()->route('login')->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
}
}
@@ -0,0 +1,47 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
class PasswordResetLinkController extends Controller
{
/**
* Display the password reset link request view.
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('auth.forgot-password');
}
/**
* Handle an incoming password reset link request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$request->validate([
'email' => ['required', 'email'],
]);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$status = Password::sendResetLink(
$request->only('email')
);
return $status == Password::RESET_LINK_SENT
? back()->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
}
}
@@ -0,0 +1,89 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Models\Role;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules;
class RegisteredUserController extends Controller
{
/**
* Display the registration view.
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('auth.register');
}
/**
* Handle an incoming registration request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function storeOrangTua(Request $request)
{
$request->validate([
'nama' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'alamat' => ['required', 'string'],
'id_desa' => ['required', 'exists:data_desa,id'],
'id_posyandu' => ['required', 'exists:data_posyandu,id'],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);
$user = User::create([
'nama' => $request->nama,
'email' => $request->email,
'alamat' => $request->alamat,
'password' => Hash::make($request->password),
'id_desa' => $request->id_desa,
'id_posyandu' => $request->id_posyandu,
]);
$role = Role::where('role', 'ORANG_TUA')->first();
$user->role()->associate($role);
$user->push();
Auth::login($user);
return redirect(RouteServiceProvider::HOME);
}
public function storePosyandu(Request $request)
{
$request->validate([
'nama' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'id_desa' => ['required', 'exists:data_desa,id'],
'id_posyandu' => ['required', 'exists:data_posyandu,id'],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);
$user = User::create([
'nama' => $request->nama,
'email' => $request->email,
'password' => Hash::make($request->password),
'id_desa' => $request->id_desa,
'id_posyandu' => $request->id_posyandu,
]);
$role = Role::where('role', 'KADER_POSYANDU')->first();
$user->role()->associate($role);
$user->push();
Auth::login($user);
return redirect(RouteServiceProvider::HOME);
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
class VerifyEmailController extends Controller
{
/**
* Mark the authenticated user's email address as verified.
*
* @param \Illuminate\Foundation\Auth\EmailVerificationRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function __invoke(EmailVerificationRequest $request)
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1');
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1');
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
+248
View File
@@ -0,0 +1,248 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Anak;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
class DataAnakController extends Controller
{
/**
* Display the registration view.
*
* @return \Illuminate\View\View
*/
public function show(Request $request)
{
$validator = validator($request->all(), [
'offset' => ['integer'],
'limit' => ['integer']
]);
if ($validator->fails()) {
return $this->errorValidationResponse("validation failed", $validator->errors());
}
$limit = $request->exists('limit') ? $request->limit : 10;
$offset = $request->exists('offset') ? $request->offset : 0;
$kaderPosyandu = User::getUser(Auth::user());
if ($kaderPosyandu->role->role == "ORANG_TUA") {
return $this->showOrangTua($request);
}
if ($kaderPosyandu->role->role == "DESA") {
return $this->showDesa($request);
}
$total = $kaderPosyandu->posyandu->anak()->count();
$anak = $kaderPosyandu->posyandu->anak();
if ($request->exists('limit')) {
$anak = $anak->limit($limit);
}
if ($request->exists('offset')) {
$anak = $anak->offset($offset);
}
$anak = $anak->get();
$laporan = [
'berat' => $kaderPosyandu->posyandu->laporanBerat(),
'tinggi' => $kaderPosyandu->posyandu->laporanTinggi(),
'lingkar_kepala' => $kaderPosyandu->posyandu->laporanLingkarKepala(),
];
$response = [
'limit' => $limit,
'offset' => $offset,
'total' => $total,
'data' => $anak,
'laporan' => $laporan,
];
return view('dashboard', $response);
}
public function showOrangTua(Request $request)
{
$validator = validator($request->all(), [
'offset' => ['integer'],
'limit' => ['integer']
]);
if ($validator->fails()) {
return $this->errorValidationResponse("validation failed", $validator->errors());
}
$limit = $request->exists('limit') ? $request->limit : 10;
$offset = $request->exists('offset') ? $request->offset : 0;
$orangTua = User::getUser(Auth::user());
$total = $orangTua->anak()->count();
$anak = $orangTua->anak();
if ($request->exists('limit')) {
$anak = $anak->limit($limit);
}
if ($request->exists('offset')) {
$anak = $anak->offset($offset);
}
$anak = $anak->get();
$response = [
'limit' => $limit,
'offset' => $offset,
'total' => $total,
'data' => $anak,
];
return view('dashboard-orang-tua', $response);
}
public function showDesa(Request $request)
{
$validator = validator($request->all(), [
'offset' => ['integer'],
'limit' => ['integer']
]);
if ($validator->fails()) {
return $this->errorValidationResponse("validation failed", $validator->errors());
}
$limit = $request->exists('limit') ? $request->limit : 10;
$offset = $request->exists('offset') ? $request->offset : 0;
$desa = User::getUser(Auth::user());
$total = $desa->desa->anak()->count();
$anak = $desa->desa->anak();
if ($request->exists('limit')) {
$anak = $anak->limit($limit);
}
if ($request->exists('offset')) {
$anak = $anak->offset($offset);
}
$anak = $anak->get();
$dataPosyandu = $desa->desa->posyandu;
$lapPosyandu = collect([]);
foreach ($dataPosyandu as $posyandu) {
$laporan = [
'berat' => $posyandu->laporanBerat($posyandu['berat_terakhir']),
'tinggi' => $posyandu->laporanTinggi($posyandu['tinggi_terakhir']),
'lingkar_kepala' => $posyandu->laporanLingkarKepala($posyandu['lingkar_kepala_terakhir']),
];
$lapPosyandu[$posyandu->nama] = $laporan;
}
$response = [
'limit' => $limit,
'offset' => $offset,
'total' => $total,
'data' => $anak,
'lap_posyandu' => $lapPosyandu,
];
return view('dashboard-desa', $response);
}
/**
* Handle an incoming registration request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$user = Auth::user();
$request->validate(
[
'nama' => ['required', 'string', 'min:3'],
'panggilan' => ['string'],
'tanggal_lahir' => ['required', 'date'],
/* 'tinggi' => ['required'], */
/* 'berat' => ['required'], */
/* 'lingkar_kepala' => ['required'], */
'nama_orang_tua' => ['required', 'string'],
'alamat' => ['string'],
'gender' => ['required', Rule::in(['LAKI_LAKI', 'PEREMPUAN'])],
'image' => ['string']
]
);
$anak = new Anak;
$anak->fill([
'nama' => $request->nama,
'panggilan' => $request->panggilan,
'tanggal_lahir' => $request->tanggal_lahir,
'alamat' => $request->alamat,
'nama_orang_tua' => $request->nama_orang_tua,
'gender' => $request->gender,
'image' => $request->image,
]);
$anak->desa()->associate($user->desa);
$anak->posyandu()->associate($user->posyandu);
$anak->save();
$anak->statistik()->create([
'tinggi' => $request->tinggi,
'berat' => $request->berat,
'lingkar_kepala' => $request->lingkar_kepala,
'z_score' => $request->z_score,
'date' => now(),
]);
$anak->push();
return redirect("/dashboard");
}
public function storeOrangTua(Request $request)
{
$user = Auth::user();
$request->validate(
[
'nama' => ['required', 'string', 'min:3'],
'panggilan' => ['string'],
'tanggal_lahir' => ['required', 'date'],
/* 'tinggi' => ['required'], */
/* 'berat' => ['required'], */
/* 'lingkar_kepala' => ['required'], */
/* 'nama_orang_tua' => ['required', 'string'], */
'alamat' => ['string'],
'gender' => ['required', Rule::in(['LAKI_LAKI', 'PEREMPUAN'])],
'image' => ['string']
]
);
$anak = new Anak;
$anak->fill([
'nama' => $request->nama,
'panggilan' => $request->panggilan,
'tanggal_lahir' => $request->tanggal_lahir,
'alamat' => $user->alamat,
'nama_orang_tua' => $user->nama,
'gender' => $request->gender,
'image' => $request->image,
]);
$anak->desa()->associate($user->desa);
$anak->posyandu()->associate($user->posyandu);
$anak->orangTua()->associate($user);
$anak->save();
$anak->statistik()->create([
'tinggi' => $request->tinggi,
'berat' => $request->berat,
'lingkar_kepala' => $request->lingkar_kepala,
'z_score' => $request->z_score,
'date' => now(),
]);
$anak->push();
return redirect("/dashboard");
}
}
@@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Anak;
class StatistikAnakController extends Controller
{
public function show($id)
{
$anak = Anak::find($id);
if (empty($anak)) {
redirect('/dashboard');
}
$response = [
'anak' => $anak,
];
return view('input-statistik', $response);
}
public function store(Request $request, $id)
{
$anak = Anak::find($id);
if (empty($anak)) {
redirect('/dashboard');
}
$anak->statistik()->create([
'tinggi' => $request->tinggi,
'berat' => $request->berat,
'lingkar_kepala' => $request->lingkar_kepala,
'z_score_tinggi' => $request->z_score_tinggi,
'z_score_berat' => $request->z_score_berat,
'z_score_lingkar_kepala' => $request->z_score_lingkar_kepala,
'date' => now(),
]);
$anak->push();
return redirect("/detail-anak/" . $anak->id);
}
}
+67
View File
@@ -0,0 +1,67 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array<int, class-string|string>
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array<string, array<int, class-string|string>>
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array<int, string>
*/
protected $except = [
//
];
}
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [
//
];
}
@@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array<int, string|null>
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array<int, string>|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array<int, string>
*/
protected $except = [
//
];
}
+93
View File
@@ -0,0 +1,93 @@
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => ['required', 'string', 'email'],
'password' => ['required', 'string'],
];
}
/**
* Attempt to authenticate the request's credentials.
*
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function authenticate()
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}
/**
* Ensure the login request is not rate limited.
*
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function ensureIsNotRateLimited()
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
return;
}
event(new Lockout($this));
$seconds = RateLimiter::availableIn($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.throttle', [
'seconds' => $seconds,
'minutes' => ceil($seconds / 60),
]),
]);
}
/**
* Get the rate limiting throttle key for the request.
*
* @return string
*/
public function throttleKey()
{
return Str::lower($this->input('email')).'|'.$this->ip();
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class DesaResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
];
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class StatistikResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
$parent = parent::toArray($request);
$statistik = [
"berat" => $this->kategoriBerat(),
"tinggi" => $this->kategoriTinggi(),
"lingkar_kepala" => $this->kategoriLingkarKepala(),
"gizi" => $this->kategoriGizi(),
];
$parent['statistik'] = $statistik;
return $parent;
}
}
+101
View File
@@ -0,0 +1,101 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class Anak extends Model
{
use HasFactory;
protected $table = 'data_anak';
protected $fillable = [
'nama',
'panggilan',
'tanggal_lahir',
'alamat',
'nama_orang_tua',
'gender',
'image',
'berat_terakhir',
'tinggi_terakhir',
'lingkar_kepala_terakhir',
'id_orang_tua',
'id_posyandu',
'id_desa',
'status'
];
public function umur($date)
{
$tanggalLahir = Carbon::createFromFormat("Y-m-d", $this->tanggal_lahir);
$carbonDate = Carbon::make($date);
$umurInBulan = $carbonDate->diffInMonths($tanggalLahir);
return $umurInBulan;
}
public function updateStatistikTerakhir()
{
$statistik = $this->statistik()->orderBy('created_at', 'desc')->first();
$this->berat_terakhir = $statistik->kategoriBerat();
$this->tinggi_terakhir = $statistik->kategoriTinggi();
$this->lingkar_kepala_terakhir = $statistik->kategoriLingkarKepala();
$this->update();
}
public function statistikTerakhir()
{
$statistik = $this->statistik()->orderBy('created_at', 'desc')->first();
return $statistik;
}
public function beratTerakhir()
{
$statistik = $this->statistik()->orderBy('created_at', 'desc')->first();
if (empty($statistik)) {
return null;
}
return $statistik->berat;
}
public function tinggiTerakhir()
{
$statistik = $this->statistik()->orderBy('created_at', 'desc')->first();
if (empty($statistik)) {
return null;
}
return $statistik->tinggi;
}
public function lingkarKepalaTerakhir()
{
$statistik = $this->statistik()->orderBy('created_at', 'desc')->first();
if (empty($statistik)) {
return null;
}
return $statistik->lingkar_kepala;
}
public function statistik()
{
return $this->hasMany(StatistikAnak::class, 'id_anak', 'id');
}
public function orangTua()
{
return $this->belongsTo(User::class, 'id_orang_tua', 'id');
}
public function desa()
{
return $this->belongsTo(Desa::class, 'id_desa', 'id');
}
public function posyandu()
{
return $this->belongsTo(Posyandu::class, 'id_posyandu', 'id');
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Artikel extends Model
{
use HasFactory;
protected $table = 'artikel';
protected $fillable = [
'judul',
'kategori',
'image',
'penulis',
'content',
];
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{
use HasFactory;
protected $fillable = [
'user_id', 'post_id', 'content'
];
public function post()
{
return $this->belongsTo(Post::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Desa extends Model
{
use HasFactory, SoftDeletes;
protected $table = 'data_desa';
protected $fillable = [
'name'
];
protected $dates = ['deleted_at'];
public function posyandu()
{
return $this->hasMany(Posyandu::class, 'id_desa', 'id');
}
public function anak()
{
return $this->hasMany(Anak::class, 'id_desa', 'id');
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Kategori extends Model
{
use HasFactory;
protected $table = 'kategori';
protected $fillable = [
'name',
];
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasFactory;
protected $fillable = [
'user_id', 'title', 'content','read'
];
public function comments()
{
return $this->hasMany(Comment::class, 'post_id', 'id');
}
public function user()
{
return $this->belongsTo(User::class);
}
}
+128
View File
@@ -0,0 +1,128 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\SoftDeletes;
class Posyandu extends Model
{
use HasFactory, SoftDeletes;
protected $table = "data_posyandu";
protected $fillable = [
'nama',
'alamat',
'latitude',
'longitude',
];
public function desa()
{
return $this->belongsTo(Desa::class, 'id_desa', 'id');
}
public function anak()
{
return $this->hasMany(Anak::class, 'id_posyandu', 'id');
}
public function jumlahAnak()
{
return $this->anak()->count();
}
public function laporanBerat($allLatsStatistik)
{
$obesitas = 0;
$gemuk = 0;
$normal = 0;
$kurus = 0;
$sangatKurus = 0;
if($allLatsStatistik != NULL){
foreach ($allLatsStatistik as $latestStatistik){
if($latestStatistik != NULL){
if ($latestStatistik->status_berat_badan == 'Gemuk') {
$gemuk++;
} else if ($latestStatistik->status_berat_badan == 'Normal') {
$normal++;
} else if ($latestStatistik->status_berat_badan == 'Kurus') {
$kurus++;
} else if ($latestStatistik->status_berat_badan == 'Sangat Kurus') {
$sangatKurus++;
}
}
}
}
return [
'gemuk' => $gemuk,
'normal' => $normal,
'kurus' => $kurus,
'sangat_kurus' => $sangatKurus,
];
}
public function laporanTinggi($allLatsStatistik)
{
$tinggi = 0;
$normal = 0;
$pendek = 0;
$sangatPendek = 0;
if($allLatsStatistik != NULL){
foreach ($allLatsStatistik as $latestStatistik){
if($latestStatistik != NULL){
if ($latestStatistik->status_tinggi_badan == 'Tinggi') {
$tinggi++;
} else if ($latestStatistik->status_tinggi_badan == 'Normal') {
$normal++;
} else if ($latestStatistik->status_tinggi_badan == 'Pendek') {
$pendek++;
} else if ($latestStatistik->status_tinggi_badan == 'Sangat Pendek') {
$sangatPendek++;
}
}
}
}
return [
'tinggi' => $tinggi,
'normal' => $normal,
'pendek' => $pendek,
'sangat_pendek' => $sangatPendek,
];
}
public function laporanLingkarKepala($allLatsStatistik)
{
$makrosefali = 0;
$normal = 0;
$mikrosefali = 0;
if($allLatsStatistik != NULL){
foreach ($allLatsStatistik as $latestStatistik){
if($latestStatistik != NULL){
if ($latestStatistik->status_lingkar_kepala == 'Makrosefali') {
$makrosefali++;
} else if ($latestStatistik->status_lingkar_kepala == 'Normal') {
$normal++;
} else if ($latestStatistik->status_lingkar_kepala == 'Mikrosefali') {
$mikrosefali++;
}
}
}
}
return [
'makrosefali' => $makrosefali,
'normal' => $normal,
'mikrosefali' => $mikrosefali,
];
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Reminder extends Model
{
use HasFactory;
protected $table = 'reminders';
protected $fillable = [
'judul',
'deskripsi',
'tanggal_reminder',
'id_desa',
];
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
use HasFactory;
protected $table = "role";
protected $fillable = [
'role'
];
}
+119
View File
@@ -0,0 +1,119 @@
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class StatistikAnak extends Model
{
use HasFactory;
protected $table = 'data_statistik_anak';
protected $fillable = [
'tinggi',
'berat',
'lingkar_kepala',
'date',
'z_score_tinggi',
'z_score_berat',
'z_score_lingkar_kepala',
'date',
'id_anak',
"status_berat_badan",
"status_tinggi_badan",
"status_lingkar_kepala",
"z_score_gizi",
"status_gizi"
];
public function anak()
{
return $this->belongsTo(Anak::class, 'id_anak', 'id');
}
public function kategoriBerat()
{
$berat = '';
$zscore = $this->z_score_berat;
if ($zscore > 2) {
$berat = 'Gemuk';
} elseif ($zscore > -2 && $zscore <= 2) {
$berat = 'Normal';
} elseif ($zscore > -3 && $zscore <= -2) {
$berat = 'Kurus';
} elseif ($zscore < -3) {
$berat = 'Sangat Kurus';
}
if (empty($this->z_score_berat)) {
return null;
}
return $berat;
}
public function kategoriTinggi()
{
$zscore = $this->z_score_tinggi;
if ($zscore > 2) {
$tinggi = 'Tinggi';
} elseif ($zscore > -2 && $zscore <= 2) {
$tinggi = 'Normal';
} elseif ($zscore > -3 && $zscore <= -2) {
$tinggi = 'Pendek';
} elseif ($zscore <= -3) {
$tinggi = 'Sangat Pendek';
}
if (empty($this->z_score_tinggi)) {
return null;
}
return $tinggi;
}
public function kategoriLingkarKepala()
{
$zscore = $this->z_score_lingkar_kepala;
if ($zscore > 2) {
$lingkarKepala = 'Makrosefali';
} elseif ($zscore > -2 && $zscore <= 2) {
$lingkarKepala = 'Normal';
} elseif ($zscore < -2) {
$lingkarKepala = 'Mikrosefali';
}
if (empty($this->z_score_lingkar_kepala)) {
return null;
}
return $lingkarKepala;
}
public function kategoriGizi()
{
$zscore = $this->z_score_gizi;
if ($zscore > 3) {
$gizi = 'Obesitas';
} elseif ($zscore > 2 && $zscore <= 3) {
$gizi = 'Gizi Lebih';
} elseif ($zscore > 1 && $zscore <= 2) {
$gizi = 'Beresiko Gizi Lebih';
} elseif ($zscore >= -2 && $zscore <= 1) {
$gizi = 'Gizi Baik';
} elseif ($zscore >= -3 && $zscore < -2) {
$gizi = 'Gizi Kurang';
} elseif ($zscore < -3) {
$gizi = 'Gizi Buruk';
}
if (empty($this->z_score_gizi)) {
return null;
}
return $gizi;
}
}
+88
View File
@@ -0,0 +1,88 @@
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'nama',
'email',
'alamat',
'password',
'id_desa',
'id_posyandu',
'status',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function role()
{
return $this->belongsTo(Role::class, 'id_role', 'id');
}
public function desa()
{
return $this->belongsTo(Desa::class, 'id_desa', 'id');
}
public function posyandu()
{
return $this->belongsTo(Posyandu::class, 'id_posyandu', 'id');
}
public function anak()
{
return $this->hasMany(Anak::class, 'id_orang_tua', 'id');
}
public function post()
{
return $this->hasMany(Post::class, 'user_id', 'id');
}
public function comments()
{
return $this->hasMany(Comment::class, 'user_id', 'id');
}
/**
* @param \Illuminate\Contracts\Auth\Authenticatable $auth
* @return User
*/
public static function getUser($user): User
{
return $user;
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
//
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
}
+68
View File
@@ -0,0 +1,68 @@
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/dashboard';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::prefix('api/auth')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/auth_api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class AppLayout extends Component
{
/**
* Get the view / contents that represents the component.
*
* @return \Illuminate\View\View
*/
public function render()
{
return view('layouts.app');
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class GuestLayout extends Component
{
/**
* Get the view / contents that represents the component.
*
* @return \Illuminate\View\View
*/
public function render()
{
return view('layouts.guest');
}
}
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any of our classes manually. It's great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);
+55
View File
@@ -0,0 +1,55 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+66
View File
@@ -0,0 +1,66 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"doctrine/dbal": "^3.3",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.83",
"laravel/sanctum": "^2.15",
"laravel/tinker": "^2.5",
"maatwebsite/excel": "^3.1"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/breeze": "^1.9",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10",
"maatwebsite/excel": "^3.1"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Generated
+8754
View File
File diff suppressed because it is too large Load Diff
+237
View File
@@ -0,0 +1,237 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL', null),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_US',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'Date' => Illuminate\Support\Facades\Date::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Http' => Illuminate\Support\Facades\Http::class,
'Js' => Illuminate\Support\Js::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
// 'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'Str' => Illuminate\Support\Str::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
],
];
+111
View File
@@ -0,0 +1,111 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];
+64
View File
@@ -0,0 +1,64 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "ably", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];
+110
View File
@@ -0,0 +1,110 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb", "octane", "null"
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
'lock_connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
'lock_connection' => 'default',
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
];
+34
View File
@@ -0,0 +1,34 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*','http://localhost:3000', 'https://gizibalita.humicprototyping.com/', 'https://responsive-gizi-balita.vercel.app/'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];
+147
View File
@@ -0,0 +1,147 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
];
+73
View File
@@ -0,0 +1,73 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];
+52
View File
@@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 65536,
'threads' => 1,
'time' => 4,
],
];
+118
View File
@@ -0,0 +1,118 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];
+118
View File
@@ -0,0 +1,118 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send any email
| messages sent by your application. Alternative mailers may be setup
| and used as needed; however, this mailer will be used by default.
|
*/
'default' => env('MAIL_MAILER', 'smtp'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers to be used while
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array", "failover"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
+93
View File
@@ -0,0 +1,93 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
'after_commit' => false,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];
+65
View File
@@ -0,0 +1,65 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Stateful Domains
|--------------------------------------------------------------------------
|
| Requests from the following domains / hosts will receive stateful API
| authentication cookies. Typically, these should include your local
| and production domains which access your API via a frontend SPA.
|
*/
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : ''
))),
/*
|--------------------------------------------------------------------------
| Sanctum Guards
|--------------------------------------------------------------------------
|
| This array contains the authentication guards that will be checked when
| Sanctum is trying to authenticate a request. If none of these guards
| are able to authenticate the request, Sanctum will use the bearer
| token that's present on an incoming request for authentication.
|
*/
'guard' => ['web'],
/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. If this value is null, personal access tokens do
| not expire. This won't tweak the lifetime of first-party sessions.
|
*/
'expiration' => null,
/*
|--------------------------------------------------------------------------
| Sanctum Middleware
|--------------------------------------------------------------------------
|
| When authenticating your first-party SPA with Sanctum you may need to
| customize some of the middleware Sanctum uses while processing the
| request. You may change the middleware listed below as required.
|
*/
'middleware' => [
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
],
];
+33
View File
@@ -0,0 +1,33 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
],
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
];
+201
View File
@@ -0,0 +1,201 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION', null),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| While using one of the framework's cache driven session backends you may
| list a cache store that should be used for these sessions. This value
| must match with one of the application's configured cache "stores".
|
| Affects: "apc", "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE', null),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => env('SESSION_DOMAIN', null),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
*/
'http_only' => true,
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" since this is a secure default value.
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => 'lax',
];
+50
View File
@@ -0,0 +1,50 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Console Commands
|--------------------------------------------------------------------------
|
| This option allows you to add additional Artisan commands that should
| be available within the Tinker environment. Once the command is in
| this array you may execute the command in Tinker using its name.
|
*/
'commands' => [
// App\Console\Commands\ExampleCommand::class,
],
/*
|--------------------------------------------------------------------------
| Auto Aliased Classes
|--------------------------------------------------------------------------
|
| Tinker will not automatically alias classes in your vendor namespaces
| but you may explicitly allow a subset of classes to get aliased by
| adding the names of each of those classes to the following list.
|
*/
'alias' => [
//
],
/*
|--------------------------------------------------------------------------
| Classes That Should Not Be Aliased
|--------------------------------------------------------------------------
|
| Typically, Tinker automatically aliases classes as you require them in
| Tinker. However, you may wish to never alias certain classes, which
| you may accomplish by listing the classes in the following array.
|
*/
'dont_alias' => [
'App\Nova',
],
];
+36
View File
@@ -0,0 +1,36 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
resource_path('views'),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => env(
'VIEW_COMPILED_PATH',
realpath(storage_path('framework/views'))
),
];
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+39
View File
@@ -0,0 +1,39 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name(),
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function unverified()
{
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
}
}
@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
/* $table->timestamp('email_verified_at')->nullable(); */
$table->string('password');
$table->rememberToken();
$table->timestamps();
$table->softDeletesTz();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}

Some files were not shown because too many files have changed in this diff Show More