tugas akhir

This commit is contained in:
lutfi01 2024-07-17 10:46:39 +07:00
commit 929f830f60
320 changed files with 67712 additions and 0 deletions

410
arduino/TA_FINAL.ino Normal file
View File

@ -0,0 +1,410 @@
#define BLYNK_TEMPLATE_ID "TMPL66b-buG9w"
#define BLYNK_TEMPLATE_NAME "Monitoring Listrik"
#define BLYNK_AUTH_TOKEN "f3xiBla2UmCX2klP4VuzaYjXZlvyulJZ"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <PZEM004Tv30.h>
#include <WiFiManager.h>
#include <BlynkSimpleEsp32.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <FS.h>
#include <ArduinoOTA.h>
#include <EEPROM.h>
// Define constants
#define BLYNK_TEMPLATE_ID_LEN 20
#define BLYNK_TEMPLATE_NAME_LEN 40
#define BLYNK_AUTH_TOKEN_LEN 40
#define MAX_LEN 40
char ssid[50];
char pass[50];
char lokasi_id[MAX_LEN];
char blynk_template_id[BLYNK_TEMPLATE_ID_LEN];
char blynk_template_name[BLYNK_TEMPLATE_NAME_LEN];
char blynk_auth_token[BLYNK_AUTH_TOKEN_LEN];
char created_at[50];
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 25200;
const int daylightOffset_sec = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2);
PZEM004Tv30 pzem(Serial2, 16, 17);
float tarifPerKWh = 1352;
const int relayPin = 5;
const int buzzerPin = 15;
int relayState = LOW;
WiFiClient client;
IPAddress serverAddr;
unsigned long lastUploadTime = 0; // Variabel untuk menyimpan waktu upload terakhir
const unsigned long uploadInterval = 60000; // Interval 1 menit (60000 ms)
unsigned long lastBlynkUpdateTime = 0; // Variabel untuk menyimpan waktu update Blynk terakhir
const unsigned long blynkUpdateInterval = 1000; // Interval 1 detik (1000 ms)
unsigned long previousMillis = 0; // Waktu sebelumnya
const long buzzerDuration = 60000; // Durasi buzzer dalam milidetik (1 menit = 60 detik = 60000 milidetik)
void setup() {
WiFi.mode(WIFI_STA);
Serial.begin(115200);
EEPROM.begin(512);
pinMode(relayPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
// Membaca data dari EEPROM
String read_lokasi_id = EEPROM.readString(0);
String read_blynk_template_id = EEPROM.readString(20);
String read_blynk_template_name = EEPROM.readString(60);
String read_blynk_auth_token = EEPROM.readString(100);
// Menampilkan data yang dibaca di Serial Monitor
Serial.println("Reading from EEPROM:");
Serial.println("lokasi_id: " + read_lokasi_id);
Serial.println("blynk_template_id: " + read_blynk_template_id);
Serial.println("blynk_template_name: " + read_blynk_template_name);
Serial.println("blynk_auth_token: " + read_blynk_auth_token);
// Inisialisasi WiFiManager
WiFiManager wifiManager;
bool needConfiguration = false;
// Memeriksa apakah data EEPROM valid
if (read_lokasi_id.length() > 0 && read_blynk_template_id.length() > 0 &&
read_blynk_template_name.length() > 0 && read_blynk_auth_token.length() > 0) {
// Data valid, gunakan untuk konfigurasi Blynk
strncpy(lokasi_id, read_lokasi_id.c_str(), sizeof(lokasi_id));
strncpy(blynk_template_id, read_blynk_template_id.c_str(), sizeof(blynk_template_id));
strncpy(blynk_template_name, read_blynk_template_name.c_str(), sizeof(blynk_template_name));
strncpy(blynk_auth_token, read_blynk_auth_token.c_str(), sizeof(blynk_auth_token));
Serial.println("Using saved data from EEPROM:");
Serial.println("lokasi_id: " + String(lokasi_id));
Serial.println("blynk_template_id: " + String(blynk_template_id));
Serial.println("blynk_template_name: " + String(blynk_template_name));
Serial.println("blynk_auth_token: " + String(blynk_auth_token));
// Coba hubungkan ke WiFi dengan SSID yang disimpan
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Connecting to");
lcd.setCursor(0, 1);
lcd.print("WiFi.........");
delay(5000);
WiFi.begin(ssid, pass);
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Failed to connect to WiFi with saved credentials. Opening configuration portal...");
needConfiguration = true;
} else {
Serial.println("Connected to WiFi with saved credentials");
// Periksa apakah SSID telah berubah
if (String(WiFi.SSID()) != String(ssid)) {
Serial.println("SSID has changed, opening configuration portal...");
needConfiguration = true;
}
}
} else {
// Data tidak valid atau kosong, buka portal konfigurasi
Serial.println("No saved data in EEPROM or data invalid. Opening configuration portal...");
needConfiguration = true;
}
if (needConfiguration) {
WiFiManagerParameter custom_lokasi_id("lokasi_id", "lokasi ID", lokasi_id, MAX_LEN);
WiFiManagerParameter custom_blynk_template_id("blynk_template_id", "Blynk Template ID", blynk_template_id, BLYNK_TEMPLATE_ID_LEN);
WiFiManagerParameter custom_blynk_template_name("blynk_template_name", "Blynk Template Name", blynk_template_name, BLYNK_TEMPLATE_NAME_LEN);
WiFiManagerParameter custom_blynk_auth_token("blynk_auth_token", "Blynk Auth Token", blynk_auth_token, BLYNK_AUTH_TOKEN_LEN);
wifiManager.addParameter(&custom_lokasi_id);
wifiManager.addParameter(&custom_blynk_template_id);
wifiManager.addParameter(&custom_blynk_template_name);
wifiManager.addParameter(&custom_blynk_auth_token);
if (!wifiManager.autoConnect("VoltTech", "password")) {
Serial.println("Failed to connect to WiFi and hit timeout");
ESP.restart();
delay(1000);
}
// Simpan parameter kustom ke variabel
strncpy(ssid, WiFi.SSID().c_str(), sizeof(ssid));
strncpy(pass, WiFi.psk().c_str(), sizeof(pass));
strncpy(lokasi_id, custom_lokasi_id.getValue(), sizeof(lokasi_id));
strncpy(blynk_template_id, custom_blynk_template_id.getValue(), sizeof(blynk_template_id));
strncpy(blynk_template_name, custom_blynk_template_name.getValue(), sizeof(blynk_template_name));
strncpy(blynk_auth_token, custom_blynk_auth_token.getValue(), sizeof(blynk_auth_token));
// Simpan parameter kustom ke EEPROM
EEPROM.writeString(0, lokasi_id);
EEPROM.writeString(20, blynk_template_id);
EEPROM.writeString(60, blynk_template_name);
EEPROM.writeString(100, blynk_auth_token);
EEPROM.commit();
// Tampilkan data yang ditulis ke EEPROM di Serial Monitor
Serial.println("Saved new data to EEPROM:");
Serial.println("lokasi_id: " + String(lokasi_id));
Serial.println("blynk_template_id: " + String(blynk_template_id));
Serial.println("blynk_template_name: " + String(blynk_template_name));
Serial.println("blynk_auth_token: " + String(blynk_auth_token));
}
// Initialize Blynk with obtained credentials
Blynk.begin(blynk_auth_token, ssid, pass);
// Menampilkan data yang digunakan ke Serial Monitor
Serial.println("Final data used:");
Serial.println("lokasi_id: " + String(lokasi_id));
Serial.println("blynk_template_id: " + String(blynk_template_id));
Serial.println("blynk_template_name: " + String(blynk_template_name));
Serial.println("blynk_auth_token: " + String(blynk_auth_token));
// Inisialisasi OTA
ArduinoOTA.begin();
buzzTwice();
uploadWireless();
lcd.init();
lcd.backlight();
lcd.print(" kWh-Meter ");
delay(2000);
lcd.clear();
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
// Ensure time is properly set up
// Wait for time to be set
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
Serial.println("Failed to obtain time");
} else {
Serial.println("Time obtained successfully");
Serial.print("Current time: ");
Serial.printf("%02d-%02d-%04d %02d:%02d:%02d\n",
timeinfo.tm_mday,
timeinfo.tm_mon + 1,
timeinfo.tm_year + 1900,
timeinfo.tm_hour,
timeinfo.tm_min,
timeinfo.tm_sec);
}
}
void loop() {
ArduinoOTA.handle();
Blynk.run();
getDateTime();
unsigned long currentMillis = millis();
// Pernyataan debugging untuk memeriksa status relayState saat ini
Serial.print("relayState: ");
Serial.println(relayState);
if (relayState == HIGH) { // Mode Otomatis Aktif
controlRelayBasedOnSensor(); // Gunakan logika kontrol otomatis jika mode Otomatis
} else { // Mode Otomatis Nonaktif
digitalWrite(relayPin, LOW); // Matikan relay
}
float voltage = pzem.voltage();
float current = pzem.current();
float powerFactor = pzem.pf();
float power = voltage * powerFactor * current;
float hours = 1;
float energy = power * (hours / 1000);
if (power >= 450) { // Aktifkan buzzer jika daya lebih besar dari atau sama dengan 5 W
digitalWrite(buzzerPin, HIGH);
if (currentMillis - previousMillis >= buzzerDuration) {
digitalWrite(buzzerPin, LOW); // Matikan buzzer setelah 1 menit
previousMillis = currentMillis; // Perbarui waktu sebelumnya
}
} else {
digitalWrite(buzzerPin, LOW);
}
Serial.println("Pembacaan Sensor:");
Serial.print("Voltage: "); Serial.print(voltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current); Serial.println(" A");
Serial.print("Power Factor: "); Serial.println(powerFactor);
Serial.print("Power: "); Serial.print(power); Serial.println(" W");
Serial.print("Energy: "); Serial.print(energy); Serial.println(" kWh");
Serial.println();
if (isnan(voltage) || isnan(current) || isnan(powerFactor)) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Error membaca");
lcd.setCursor(0, 1);
lcd.print("sensor");
} else {
float biaya = (energy * tarifPerKWh);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Voltage: "); lcd.print(voltage); lcd.print("V");
lcd.setCursor(0, 1);
lcd.print("Power: "); lcd.print(power); lcd.print("W");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Pf: "); lcd.print(powerFactor);
lcd.setCursor(0, 1);
lcd.print("Energy: "); lcd.print(energy); lcd.print("kWh");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Current: "); lcd.print(current); lcd.print("A");
lcd.setCursor(0, 1);
lcd.print("Biaya: Rp. "); lcd.print(biaya, 2);
delay(2000);
unsigned long currentTime = millis();
if (currentTime - lastBlynkUpdateTime >= blynkUpdateInterval) {
// Upload data ke Blynk
Blynk.virtualWrite(V2, voltage);
Blynk.virtualWrite(V3, current);
Blynk.virtualWrite(V4, powerFactor);
Blynk.virtualWrite(V5, power);
Blynk.virtualWrite(V6, energy);
Blynk.virtualWrite(V7, biaya);
lastBlynkUpdateTime = currentTime;
}
if (currentTime - lastUploadTime >= uploadInterval) {
int lokasi_id_int = atoi(lokasi_id);
// Upload data ke server
sendHttpPost(lokasi_id_int, voltage, power, powerFactor, energy, current, biaya, created_at);
lastUploadTime = currentTime;
}
}
}
void controlRelayBasedOnSensor() {
float power = pzem.power();
if (power >= 500) {
digitalWrite(relayPin, LOW); // Matikan relay jika daya lebih dari atau sama dengan 20 W
relayState = LOW; // Simpan status relay
} else {
digitalWrite(relayPin, HIGH); // Hidupkan relay jika daya kurang dari 20 W
relayState = HIGH; // Simpan status relay
}
}
void sendHttpPost(int lokasi_id, float voltage, float power, float powerFactor, float energy, float current, float biaya, const char* created_at) {
if (WiFi.status() == WL_CONNECTED) { // Pastikan WiFi terhubung
HTTPClient http;
Serial.println("Memulai HTTP POST...");
http.begin("https://kantorku.cloud/voltech/upload/sensor_data.php");
http.addHeader("Content-Type", "application/json");
StaticJsonDocument<200> jsonDoc;
jsonDoc["lokasi_id"] = lokasi_id;
jsonDoc["voltage"] = voltage;
jsonDoc["power"] = power;
jsonDoc["power_factor"] = powerFactor;
jsonDoc["energy"] = energy;
jsonDoc["current"] = current;
jsonDoc["biaya"] = biaya;
jsonDoc["created_at"] = created_at;
String jsonString;
serializeJson(jsonDoc, jsonString);
// Debugging: Cetak payload JSON
Serial.print("Payload JSON: ");
Serial.println(jsonString);
// Kirim permintaan POST dengan payload JSON
int httpResponseCode = http.POST(jsonString);
if (httpResponseCode > 0) {
Serial.print("Kode Respons HTTP: ");
Serial.println(httpResponseCode);
String response = http.getString();
Serial.println("Respons dari server: " + response);
} else {
Serial.print("Kode Kesalahan: ");
Serial.println(httpResponseCode);
}
http.end();
} else {
Serial.println("WiFi tidak terhubung");
}
}
void uploadWireless() {
ArduinoOTA
.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = "sketch";
else // U_SPIFFS
type = "filesystem";
Serial.println("Start updating " + type);
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void getDateTime() {
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
Serial.println("Failed to obtain time");
snprintf(created_at, sizeof(created_at), "0000-00-00 00:00:00");
} else {
snprintf(created_at, sizeof(created_at), "%04d-%02d-%02d %02d:%02d:%02d",
timeinfo.tm_year + 1900,
timeinfo.tm_mon + 1,
timeinfo.tm_mday,
timeinfo.tm_hour,
timeinfo.tm_min,
timeinfo.tm_sec);
}
}
BLYNK_WRITE(V1) {
relayState = param.asInt(); // Mengubah status relay berdasarkan tombol Blynk V1
Serial.print("Relay state changed to: ");
Serial.println(relayState);
// Balikkan logika relay untuk modul relay aktif rendah
if (relayState == 1) {
digitalWrite(relayPin, LOW); // Hidupkan relay jika tombol Blynk diaktifkan
} else {
digitalWrite(relayPin, HIGH); // Matikan relay jika tombol Blynk dinonaktifkan
}
}
void buzzTwice() {
for (int i = 0; i < 2; i++) {
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
}
}

18
website/.editorconfig Normal file
View File

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

58
website/.env.example Normal file
View File

@ -0,0 +1,58 @@
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=water_monitoring
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=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=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
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_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

11
website/.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
* text=auto eol=lf
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

19
website/.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode

90
website/README.md Normal file
View File

@ -0,0 +1,90 @@
<p align="center">
<img align="center" src="http://ForTheBadge.com/images/badges/built-with-love.svg"> <img align="center" src="http://ForTheBadge.com/images/badges/uses-html.svg"> <img align="center" src="http://ForTheBadge.com/images/badges/makes-people-smile.svg"> <img align="center" src="http://ForTheBadge.com/images/badges/built-by-developers.svg">
</p>
# Sistem Monitoring Kualitas Air untuk Budidaya Lele memakai framework Laravel 10
Sistem monitoring kualitas air untuk budidaya lele yang menggunakan Internet of Things (IoT) merupakan solusi modern yang memanfaatkan teknologi sensor dan konektivitas internet untuk memantau dan mengelola kondisi lingkungan air pada kolam budidaya lele secara real-time. Sistem ini dirancang untuk meningkatkan efisiensi operasional, mencegah kerugian, dan mendukung keberhasilan budidaya lele.
## Siapa pembuat aplikasi ini?
| Profile | Keterangan |
|----------------|----------------------------------|
| Nama | Bagus Budi Satoto |
| Jurusan | S1 - Informatika |
| Kampus | Universitas Amikom Yogyakarta |
## Login
User : bagussatoto <br>
Password : 12345
Atau klik [Disini](https://github.com/bagussatoto/monitoring-ikan-lele/commit/bbca23f459f992d34f4d54e5b49dfbb17d2390ac#r135821760)
## Tampilan Website
![home](https://github.com/bagussatoto/monitoring-web/assets/87259393/710b5bbe-5c49-4508-9a15-0b4288937fbd)
![rekap](https://github.com/bagussatoto/monitoring-web/assets/87259393/846d63e7-4d61-4a4f-9b69-0ee99c82c66a)
![admin](https://github.com/bagussatoto/monitoring-web/assets/87259393/b29a6666-6a5d-4862-8aea-b41bf2f84dc0)
## Penjelasan
|<h3>Notes </h3> | Keterangan |
|-----------------------|-----------------------------------------------------------------------------------|
|<b>Sensor Kualitas Air | </b>Sistem ini dilengkapi dengan berbagai jenis sensor untuk mengukur parameter kualitas air yang kritis, seperti suhu, pH, kadar oksigen terlarut (DO), amonia, nitrat, dan nitrit. Sensor-sensor ini secara terus-menerus mengumpulkan data dan mengirimkannya ke platform monitoring. |
|<b>Node IoT | </b>Setiap kolam budidaya lele dilengkapi dengan node IoT yang berfungsi sebagai pusat pengumpulan data. Node ini dapat berkomunikasi dengan sensor-sensor kualitas air dan mentransmisikan data melalui jaringan internet. |
|<b>Analisis Data | </b>Data kualitas air yang dikumpulkan selama periode waktu tertentu dianalisis secara otomatis. Analisis ini dapat memberikan wawasan tentang tren, pola, dan potensi masalah yang perlu diatasi. |
|<b>Integrasi Sistem | </b>Sistem monitoring kualitas air dapat diintegrasikan dengan sistem otomatisasi lainnya, seperti sistem pemberian pakan otomatis atau sistem pengatur suhu, untuk menciptakan solusi terintegrasi yang mendukung keberhasilan budidaya lele secara menyeluruh. |
## Cara Instalasi ke Server Lokal :
- Follow Github Saya
- Star Repo Github Saya
- Fork Repo Github Saya
- Clone project repo saya dengan cara menuliskan pada terminal/cmd/git bash :<br> <b>git clone</b>
``````
git clone https://github.com/bagussatoto/monitoring-ikan-lele.git
``````
- lalu masuk ke direktori repo yg sudah di clone dengan ketik lg pada terminal/cmd/git bash <b>cd monitoring-ikan-lele</b>
- lalu ketik <b>composser install </b> dan <b>php artisan key generate</b>
- tulis migrate database pada terminal/cmd/git bash : <b>php artisan migrate:install</b>
- jalankan php artisan db:seed pada terminal/cmd/git bash : <b>php artisan db:seed</b>
<b>Notes :</b> Untuk db:seed jika males untuk mengetikan data, akan dibuatkan langsung oleh laravelnya.
## Alat Yang Digunakan Untuk Membuat Web :
- WAMP
- Visual Studio Code
- Git
- Cloud (Github)
- PHP 7.4.9
- MYSQL 8.0.13
- Laravel 10
- Bootstrap 7
- Composer
## Kritik dan Saran
| *_Silahkan kirim kritik dan saran anda ke email :_* |
|------------------------------------------------------|
| bagusbudi1308@gmail.com |
## Request Fitur Baru dan Pelaporan Bug
Anda dapat meminta fitur baru maupun melaporkan bug melalui menu [**issues**](https://github.com/bagussatoto/monitoring-web/issues) yang sudah disediakan oleh GitHub (lihat menu di atas), posting issues baru dan kita akan berdiskusi disana.
## Berkontribusi
Siapapun dapat berkontribusi pada proyek ini mulai dari pemrograman, pembuakan buku manual, sampai dengan mengenalkan produk ini kepada **mahasiswa**.
Untuk belajar agar mengurangi kesenjangan pendidikan teknologi dengan cara membuat postingan issue di repository ini.
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
</p>

View File

@ -0,0 +1,50 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Control;
use App\Models\Monitoring;
class StoreControlData extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'store:control-data';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Store control data every hour';
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/
public function handle()
{
$monitoringData = Monitoring::latest()->first();
if ($monitoringData) {
$controlData = [
'temperature' => $monitoringData->temperature,
'turbidity' => $monitoringData->turbidity,
'ph' => $monitoringData->ph,
'jarak' => $monitoringData->jarak,
'pompa_masuk' => $monitoringData->pompa_masuk,
'pompa_keluar' => $monitoringData->pompa_keluar,
];
Control::create($controlData);
}
}
}

View File

@ -0,0 +1,28 @@
<?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.
*/
protected function schedule(Schedule $schedule): void
{
// $schedule->command('store:control-data')->everyMinute();
$schedule->command('store:control-data')->hourly();
}
/**
* Register the commands for the application.
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class MyEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
public function __construct($message)
{
$this->message = $message;
}
public function broadcastOn()
{
return ['my-channel'];
}
public function broadcastAs()
{
return 'my-event';
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*/
public function register(): void
{
$this->reportable(function (Throwable $e) {
//
});
}
}

View File

@ -0,0 +1,150 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use App\Models\LokasiMonitoring;
class AdminController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function dashboard()
{
return view('admin.dashboard', ['title' => 'Admin']);
}
public function index()
{
$users = User::paginate(10);
return view('admin.users.index', ['users' => $users, 'title' => 'Admin']);
}
public function searchUsers(Request $request)
{
$query = $request->input('query');
$users = User::where('username', 'LIKE', "%{$query}%")
->orWhere('name', 'LIKE', "%{$query}%")
->orWhere('email', 'LIKE', "%{$query}%")
->paginate(10);
return view('admin.dashboard', [
'users' => $users,
'query' => $query,
'title' => 'Admin'
]);
}
public function listLokasi($userId)
{
$user = User::findOrFail($userId);
$lokasiMonitoring = LokasiMonitoring::where('user_id', $userId)->get();
return view('admin.dashboard', [
'user' => $user,
'lokasiMonitoring' => $lokasiMonitoring,
'title' => 'Admin'
]);
}
public function updateBlynkToken(Request $request, $lokasiId)
{
$lokasi = LokasiMonitoring::findOrFail($lokasiId);
$lokasi->blynk_token = $request->input('blynk_token');
$lokasi->save();
return redirect()->back()->with('success', 'Blynk token updated successfully.');
}
public function searchLokasi(Request $request, $userId)
{
$query = $request->input('query');
$user = User::findOrFail($userId);
$lokasiMonitoring = LokasiMonitoring::where('user_id', $userId)
->where('nama_lokasi', 'LIKE', "%{$query}%")
->get();
return view('admin.dashboard', [
'user' => $user,
'lokasiMonitoring' => $lokasiMonitoring,
'query' => $query,
'title' => 'Admin'
]);
}
public function create()
{
$title = 'Admin';
return view('admin.users.create', compact('title'));
}
public function store(Request $request)
{
$request->validate([
'name' => 'required',
'username' => ['required', 'alpha_dash', 'max:255', 'unique:users'],
'email' => 'required|email|unique:users',
'password' => 'required|min:6|confirmed',
]);
User::create([
'name' => $request->name,
'email' => $request->email,
'username' => $request->username,
'password' => Hash::make($request->password),
'status' => $request->status ?? true,
]);
return redirect()->route('admin.users.index')->with('success', 'User created successfully.');
}
public function edit(User $user)
{
$title = 'Admin';
return view('admin.users.edit', compact('user', 'title'));
}
public function update(Request $request, User $user)
{
$request->validate([
'name' => 'required|string|max:255',
'username' => ['required', 'alpha_dash', 'max:255', 'unique:users,username,' . $user->id],
'email' => 'required|string|email|max:255|unique:users,email,' . $user->id,
'password' => 'nullable|string|min:6|confirmed',
]);
$user->name = $request->name;
$user->username = $request->username;
$user->email = $request->email;
if ($request->filled('password')) {
$user->password = Hash::make($request->password);
}
$user->status = $request->status ?? $user->status;
$user->save();
return redirect()->route('admin.users.index')->with('success', 'User updated successfully.');
}
public function destroy(User $user)
{
$user->delete();
return redirect()->route('admin.users.index')->with('success', 'User deleted successfully.');
}
public function toggleStatus(User $user)
{
$user->status = !$user->status;
$user->save();
return redirect()->route('admin.users.index')->with('success', 'User status updated successfully.');
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AuthenticatedSessionController extends Controller
{
public function create()
{
return view('login.index', ['title' => 'Login']);
}
public function store(Request $request)
{
$credentials = $request->validate([
'username' => ['required', 'string'],
'password' => ['required', 'string'],
]);
if (Auth::attempt($credentials)) {
$request->session()->regenerate();
if (Auth::user()->is_admin) {
return redirect()->route('admin.dashboard');
}
return redirect()->intended('/dashboard');
}
return back()->withErrors([
'username' => 'The provided credentials do not match our records.',
])->onlyInput('username');
}
public function destroy(Request $request)
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Http\Controllers;
use App\Models\Control;
use App\Http\Requests\StoreControlRequest;
use App\Http\Requests\UpdateControlRequest;
class ControlController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreControlRequest $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(Control $control)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Control $control)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateControlRequest $request, Control $control)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Control $control)
{
//
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, ValidatesRequests;
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\SensorData;
class DashboardController extends Controller
{
public function index()
{
$SensorData = SensorData::latest()->paginate(5); // Mendapatkan semua data sensor tanah
$title = "Dashboard | Histories"; // Anda juga bisa menetapkan nilai variabel $title di sini
return view('dashboard.index', [
'SensorData' => $SensorData, // Melewatkan variabel $dataSensorSoil ke tampilan
'title' => $title, // Melewatkan variabel $title ke tampilan
]);
}
}

View File

@ -0,0 +1,120 @@
<?php
namespace App\Http\Controllers;
use App\Models\SensorData;
use App\Models\LokasiMonitoring;
use Illuminate\Http\Request;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
class DashboardHistoryController extends Controller
{
public function index(Request $request)
{
$user = Auth::user();
// Query data from the SensorData model
$sensordata = SensorData::query();
// Retrieve and store the start_date and end_date query parameters
$start_date = $request->input('start_date');
$end_date = $request->input('end_date');
// Filter data based on the date range if start_date and end_date are provided
if ($start_date && $end_date) {
$startDate = Carbon::createFromFormat('Y-m-d H:i', $start_date);
$endDate = Carbon::createFromFormat('Y-m-d H:i', $end_date);
$sensordata->whereBetween('created_at', [$startDate, $endDate]);
}
// Retrieve and store the lokasi_id query parameter
$lokasiId = $request->input('lokasi_id');
// Filter data based on lokasi_id if it is provided
if ($lokasiId) {
$sensordata->where('lokasi_id', $lokasiId)->whereHas('lokasiMonitoring', function ($query) use ($user) {
$query->where('user_id', $user->id);
});
} else {
// Filter data only by lokasiMonitoring owned by the user
$sensordata->whereHas('lokasiMonitoring', function ($query) use ($user) {
$query->where('user_id', $user->id);
});
}
// Mendapatkan data lokasi dari model Lokasi yang dimiliki oleh user saat ini
$lokasiOptions = LokasiMonitoring::where('user_id', $user->id)->pluck('nama_lokasi', 'id');
// Pagination with the query parameters start_date and end_date
$sensordata = $sensordata->latest()->paginate(15)->appends(['start_date' => $start_date, 'end_date' => $end_date, 'lokasi_id' => $lokasiId]);
// Return data to the view, sorted from newest to oldest
return view('dashboard.histories.index', [
'title' => 'Dashboard | Histories',
'today' => Carbon::now()->format('Y-m-d'),
'sensordata' => $sensordata,
'lokasi_monitoring' => $lokasiOptions,
]);
}
public function cetak(Request $request)
{
$user = Auth::user();
$sensordata = SensorData::query();
$lokasiName = $request->input('lokasi_name');
$start_date = $request->input('start_date');
$end_date = $request->input('end_date');
if ($start_date && $end_date) {
$startDate = Carbon::parse($start_date)->startOfDay();
$endDate = Carbon::parse($end_date)->endOfDay();
$sensordata->whereBetween('created_at', [$startDate, $endDate]);
}
$lokasiId = $request->input('lokasi_id');
if ($lokasiId) {
$lokasimonitoring = LokasiMonitoring::find($lokasiId);
if ($lokasimonitoring) {
$sensordata->where('lokasi_id', $lokasiId)->whereHas('lokasiMonitoring', function ($query) use ($user) {
$query->where('user_id', $user->id);
});
} else {
return redirect()->back()->withErrors('Lokasi tidak ditemukan.');
}
} else {
$sensordata->whereHas('lokasiMonitoring', function ($query) use ($user) {
$query->where('user_id', $user->id);
});
$lokasimonitoring = null; // or any default value indicating all locations
}
return view('dashboard.histories.cetakhistory', [
'title' => 'Dashboard | Cetak History',
'sensorData' => $sensordata->latest()->get(),
'lokasiMonitoring' => $lokasimonitoring,
'lokasi_name' => $lokasiName ?? 'Semua Lokasi',
'start_date' => $start_date,
'end_date' => $end_date
]);
}
public function show($id)
{
$lokasimonitoring = LokasiMonitoring::findOrFail($id);
$sensordata = SensorData::where('lokasi_id', $lokasimonitoring->id)->get();
return view('data-monitoring', [
'lokasiMonitoring' => $lokasimonitoring,
'sensorData' => $sensordata
]);
}
public function destroy(SensorData $control)
{
$date = $control->created_at->format('Y-m-d');
$control->delete();
return redirect('/dashboard/sensordata?filter=' . $date)->with('success', 'Data berhasil dihapus!');
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function index()
{
return view('home', [
'title' => 'Home',
]);
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
class LoginController extends Controller
{
public function index()
{
return view('login.index', [
'title' => 'Login',
]
);
}
public function authenticate(Request $request)
{
$credentials = $request->validate([
'username' => ['required', 'alpha_dash', 'max:255'],
'password' => ['required'],
]);
if ($user && !$user->status) {
return back()->with('loginError', 'Akun Anda dinonaktifkan. Mohon hubungi admin untuk mengaktifkannya.');
}
if (Auth::attempt($credentials)) {
$request->session()->regenerate();
return redirect()->intended('/dashboard');
}
return back()->with('loginError', 'username atau password salah.');
}
public function logout(Request $request)
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
}

View File

@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers;
use App\Models\LokasiMonitoring;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class LokasiController extends Controller
{
/**
* Display a listing of the user's lokasi_monitoring.
*/
public function index()
{
$user = Auth::user();
$lokasi_monitoring = LokasiMonitoring::where('user_id', $user->id)->get();
$title = "Dashboard | Daftar Lokasi"; // Anda juga bisa menetapkan nilai variabel $title di sini
return view('dashboard.lokasi.index', compact('lokasi_monitoring','title'));
}
/**
* Show the form for creating a new lokasi.
*/
public function create()
{
$users = User::all();
$title = "Dashboard | Tambah Lokasi"; // Anda juga bisa menetapkan nilai variabel $title di sini
return view('dashboard.lokasi.create', compact('users', 'title'));
}
/**
* Store a newly created kebun in storage.
*/
public function store(Request $request)
{
$request->validate([
'nama_lokasi' => 'required|string|max:255',
'alamat' => 'required|string|max:255',
'deskripsi' => 'required|string|max:255',
]);
LokasiMonitoring::create([
'nama_lokasi' => $request->nama_lokasi,
'alamat' => $request->alamat,
'deskripsi' => $request->deskripsi,
'user_id' => Auth::id(),
]);
return redirect()->route('lokasi.index')->with('success', 'Lokasi berhasil ditambahkan');
}
/**
* Display the specified lokasi.
*/
public function show(LokasiMonitoring $lokasi)
{
$this->authorize('view', $lokasi);
return view('lokasi.show', compact('lokasi'));
}
/**
* Show the form for editing the specified lokasi.
*/
public function edit(LokasiMonitoring $lokasi)
{
$this->authorize('update', $lokasi);
return view('lokasi.edit', compact('lokasi'));
}
public function update(Request $request, LokasiMonitoring $lokasi)
{
$this->authorize('update', $lokasi);
$request->validate([
'nama_lokasi' => 'required|string|max:255',
'alamat' => 'required|string|max:255',
'deskripsi' => 'required|string|max:255',
]);
$lokasi->update($request->all());
return redirect()->route('lokasi.index')->with('success', 'Lokasi berhasil diperbarui');
}
public function destroy(LokasiMonitoring $lokasi)
{
$this->authorize('delete', $lokasi);
$lokasi->delete();
return redirect()->route('lokasi.index')->with('success', 'Lokasi berhasil dihapus');
}
public function getLokasiByUser(Request $request)
{
$user = $request->user();
$lokasi = LokasiMonitoring::where('user_id', $user->id)->get(['id', 'nama_lokasi']); // Sesuaikan dengan nama kolom tabel Anda
return response()->json($lokasi);
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class ProfileController extends Controller
{
public function edit()
{
$user = Auth::user();
$title = 'Admin';
return view('profile.edit', compact('user','title'));
}
public function update(Request $request)
{
$user = Auth::user();
$request->validate([
'name' => ['required', 'string', 'max:255'],
'username' => ['required', 'string', 'max:255', 'unique:users,username,' . $user->id],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email,' . $user->id],
'password' => ['nullable', 'string', 'min:8', 'confirmed'],
]);
$user->name = $request->name;
$user->username = $request->username;
$user->email = $request->email;
if ($request->filled('password')) {
$user->password = Hash::make($request->password);
}
$user->save();
return redirect()->route('profile.edit')->with('success', 'Profile updated successfully.');
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Mail;
use App\Mail\VerifyMail;
use App\Http\Controllers\Controller;
class RegisterController extends Controller
{
public function create()
{
return view('Registrasi.index', [
'title' => 'Registrasi'
]);
}
public function store(Request $request)
{
$validatedData = $request->validate([
'name' => 'required|alpha_dash|max:255|unique:users,name',
'username' => 'required|alpha_dash|max:255|unique:users,username',
'email' => 'required|email|max:255|unique:users,email',
'password' => 'required|min:6|confirmed',
]);
$user = User::create([
'name' => $validatedData['name'],
'username' => $validatedData['username'],
'email' => $validatedData['email'],
'password' => bcrypt($validatedData['password']),
'status' => 0,
]);
// Generate verification URL
$verificationUrl = URL::temporarySignedRoute(
'verification.verify',
now()->addMinutes(60),
['id' => $user->id, 'hash' => sha1($user->email)]
);
// Send verification email
Mail::to($user->email)->send(new VerifyMail($user, $verificationUrl));
// Redirect to email verification notice page
return redirect()->route('login')->with('success', 'Akun berhasil dibuat. Silakan verifikasi email Anda sebelum login.');
}
}

View File

@ -0,0 +1,186 @@
<?php
namespace App\Http\Controllers;
use App\Models\SensorData;
use App\Models\LokasiMonitoring;
use Illuminate\Http\Request;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
class SensorDataController extends Controller
{
public function index()
{
$user = Auth::user();
$lokasi_monitoring = LokasiMonitoring::where('user_id', $user->id)->get();
$sensor_data = SensorData::whereIn('lokasi_id', $lokasi_monitoring->pluck('id'))
->orderBy('created_at', 'desc') // Order by creation date
->take(5) // Take the latest 5 records
->get();
$title = "Dashboard | Daftar Lokasi"; // Anda juga bisa menetapkan nilai variabel $title di sini
return view('dashboard.index', compact('lokasi_monitoring','title', 'sensor_data'));
}
public function bacavoltage()
{
$sensorlatestData = SensorData::latest()->first();
return response()->json($sensorlatestData->voltage);
}
public function bacapower()
{
$sensorlatestData = SensorData::latest()->first();
return response()->json($sensorlatestData->power);
}
public function bacapowerfactor()
{
$sensorlatestData = SensorData::latest()->first();
return response()->json($sensorlatestData->power_factor);
}
public function bacaenergy()
{
$sensorlatestData = SensorData::latest()->first();
return response()->json($sensorlatestData->energy);
}
public function bacacurrent()
{
$sensorlatestData = SensorData::latest()->first();
return response()->json($sensorlatestData->current);
}
public function bacabiaya()
{
$sensorlatestData = SensorData::latest()->first();
return response()->json($sensorlatestData->biaya);
}
public function updateSwitch1(Request $request) {
// Tangani logika untuk memperbarui status switch 1
$status = $request->input('status');
// Simpan status switch 1
return response()->json(['success' => true]);
}
public function getBlynkToken(Request $request)
{
// Ambil nama lokasi dari request
$namaLokasi = $request->input('lokasi');
// Cari lokasi berdasarkan nama
$lokasi = LokasiMonitoring::where('name', $namaLokasi)->first();
// Jika lokasi ditemukan, kembalikan token Blynk
if ($lokasi) {
return response()->json(['blynk_token' => $lokasi->blynk_token]);
}
// Jika lokasi tidak ditemukan, kembalikan pesan kesalahan
return response()->json(['error' => 'Lokasi tidak ditemukan'], 404);
}
public function updateBlynkToken(Request $request)
{
// Ambil token baru dari permintaan
$newToken = $request->input('token');
// Ambil nama lokasi yang sedang dipilih oleh pengguna
$selectedLokasi = $request->input('lokasi');
// Cari lokasi berdasarkan nama
$lokasi = LokasiMonitoring::where('nama_lokasi', $selectedLokasi)->first();
// Jika lokasi ditemukan, perbarui token Blynk-nya
if ($lokasi) {
$lokasi->blynk_token = $newToken;
$lokasi->save(); // Simpan perubahan
// Beri respons bahwa token telah diperbarui
return response()->json(['message' => 'Token Blynk berhasil diperbarui']);
}
// Jika lokasi tidak ditemukan, kembalikan pesan kesalahan
return response()->json(['error' => 'Lokasi tidak ditemukan'], 404);
}
public function getLokasiInfo(Request $request)
{
$token = $request->input('token');
$lokasi = LokasiMonitoring::where('blynk_token', $token)->first();
if ($lokasi) {
$user = $lokasi->user;
return response()->json([
'nama_lokasi' => $lokasi->nama_lokasi,
'alamat' => $lokasi->alamat,
'deskripsi' => $lokasi->deskripsi,
'users' => $user->name,
]);
} else {
return response()->json(['error' => 'Lokasi not found'], 404);
}
}
public function getData(Request $request) {
$lokasiId = $request->input('lokasi_id');
$range = $request->input('range');
$query = \DB::table('sensor_data')->where('lokasi_id', $lokasiId);
if ($range == '1jam') {
$data = $query->selectRaw('DATE_FORMAT(created_at, "%Y-%m-%d %H:%i") as created_at, AVG(voltage) as avg_voltage, AVG(power) as avg_power, AVG(power_factor) as avg_power_factor, AVG(energy) as avg_energy, AVG(current) as avg_current, SUM(biaya) as sum_biaya')
->where('created_at', '>=', \Carbon\Carbon::now()->subHour())
->groupBy('created_at')
->orderBy('created_at', 'desc')
->take(60)
->get();
} elseif ($range == '1hari') {
$data = $query->selectRaw('DATE_FORMAT(created_at, "%Y-%m-%d %H") as date, AVG(voltage) as avg_voltage, AVG(power) as avg_power, AVG(power_factor) as avg_power_factor, AVG(energy) as avg_energy, AVG(current) as avg_current, SUM(biaya) as sum_biaya')
->where('created_at', '>=', \Carbon\Carbon::now()->subDay())
->groupBy('date')
->orderBy('date', 'desc')
->take(24)
->get();
} elseif ($range == '1minggu') {
$data = $query->selectRaw('DATE(created_at) as date, AVG(voltage) as avg_voltage, AVG(power) as avg_power, AVG(power_factor) as avg_power_factor, AVG(energy) as avg_energy, AVG(current) as avg_current, SUM(biaya) as sum_biaya')
->where('created_at', '>=', \Carbon\Carbon::now()->subWeek())
->groupBy('date')
->orderBy('date', 'desc')
->take(7)
->get();
} elseif ($range == '1bulan') {
$data = $query->selectRaw('DATE(created_at) as date, AVG(voltage) as avg_voltage, AVG(power) as avg_power, AVG(power_factor) as avg_power_factor, AVG(energy) as avg_energy, AVG(current) as avg_current, SUM(biaya) as sum_biaya')
->where('created_at', '>=', \Carbon\Carbon::now()->subMonth())
->groupBy('date')
->orderBy('date', 'desc')
->take(30)
->get();
} else {
return response()->json(['error' => 'Invalid range specified'], 400);
}
return response()->json($data);
}
public function getWeeklyEnergyCost(Request $request)
{
$lokasiId = $request->input('lokasi_id');
$tarif = 1352; // Tarif listrik per unit energi
$data = \DB::table('sensor_data')
->selectRaw('DATE(created_at) as date, SUM(energy) as sum_energy, (SUM(energy) * ?) as total_biaya', [$tarif])
->where('lokasi_id', $lokasiId)
->where('created_at', '>=', \Carbon\Carbon::now()->subDay())
->groupBy('date')
->orderBy('date', 'desc')
->take(7)
->get();
return response()->json($data);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Models\User;
class VerificationController extends Controller
{
public function verify(Request $request, $id, $hash)
{
$user = User::find($id);
if (!$user || !hash_equals((string) $hash, sha1($user->email))) {
return redirect('/login')->with('error', 'Invalid verification link.');
}
if ($user->hasVerifiedEmail()) {
return redirect('/login')->with('info', 'Email already verified.');
}
$user->markEmailAsVerified();
$user->status = 1;
$user->save();
return redirect('/login')->with('success', 'Email verified successfully. You can now log in.');
}
}

View File

@ -0,0 +1,71 @@
<?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,
\Illuminate\Http\Middleware\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\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\CheckUserStatus::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's middleware aliases.
*
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
*
* @var array<string, class-string|string>
*/
protected $middlewareAliases = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::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,
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'admin' => \App\Http\Middleware\AdminMiddleware::class,
'checkStatus' => \App\Http\Middleware\CheckUserStatus::class,
];
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AdminMiddleware
{
public function handle(Request $request, Closure $next)
{
if (Auth::check() && Auth::user()->is_admin) {
return $next($request);
}
return redirect('/login');
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*/
protected function redirectTo(Request $request): ?string
{
return $request->expectsJson() ? null : route('login');
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class CheckUserStatus
{
public function handle($request, Closure $next)
{
if (Auth::check() && !Auth::user()->status) {
Auth::logout();
return redirect('/login')->with('loginError', 'Akun Anda dinonaktifkan. Mohon hubungi admin untuk mengaktifkannya.');
}
return $next($request);
}
}

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 = [
//
];
}

View File

@ -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 = [
//
];
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
class RedirectIfAuthenticated
{
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
if (Auth::user()->is_admin) {
return redirect('/admin/dashboard');
}
return redirect('/home');
}
}
return $next($request);
}
}

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',
];
}

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(): array
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

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;
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
class ValidateSignature extends Middleware
{
/**
* The names of the query string parameters that should be ignored.
*
* @var array<int, string>
*/
protected $except = [
// 'fbclid',
// 'utm_campaign',
// 'utm_content',
// 'utm_medium',
// 'utm_source',
// 'utm_term',
];
}

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 = [
//
];
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreControlRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreMonitoringRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateControlRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateMonitoringRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class VerifyMail extends Mailable
{
use Queueable, SerializesModels;
public $user;
public $verificationUrl;
/**
* Create a new message instance.
*/
public function __construct($user, $verificationUrl)
{
$this->user = $user;
$this->verificationUrl = $verificationUrl;
}
/**
* Build the message.
*/
public function build()
{
return $this->subject('Verify Your Email Address')
->view('mail.verify')
->with([
'user' => $this->user,
'verificationUrl' => $this->verificationUrl,
]);
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Control extends Model
{
use HasFactory;
protected $guarded = ['id'];
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LokasiMonitoring extends Model
{
use HasFactory;
protected $table = 'lokasi_monitoring';
protected $fillable = [
'user_id',
'nama_lokasi',
'alamat',
'blynk_token',
'deskripsi',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function sensorData()
{
return $this->hasMany(SensorData::class, 'lokasi_id');
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class SensorData extends Model
{
use HasFactory;
protected $table = 'sensor_data'; // sesuaikan dengan nama tabel yang digunakan
protected $primaryKey = 'id';
protected $fillable = [
'lokasi_id',
'voltage',
'power',
'power_factor',
'energy',
'current',
'biaya',
];
public function lokasiMonitoring()
{
return $this->belongsTo(LokasiMonitoring::class, 'lokasi_id');
}
}

View File

@ -0,0 +1,52 @@
<?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;
class User extends Authenticatable implements MustVerifyEmail
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'username',
'email',
'password',
'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 lokasiMonitoring()
{
return $this->hasMany(LokasiMonitoring::class);
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\Control;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class ControlPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
//
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Control $control): bool
{
//
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
//
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Control $control): bool
{
//
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Control $control): bool
{
//
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Control $control): bool
{
//
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Control $control): bool
{
//
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace App\Policies;
use App\Models\LokasiMonitoring;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class LokasiPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can update the kebun.
*/
public function update(User $user, LokasiMonitoring $lokasimonitoring)
{
return $user->id === $lokasimonitoring->user_id;
}
/**
* Determine whether the user can delete the kebun.
*/
public function delete(User $user, LokasiMonitoring $lokasimonitoring)
{
return $user->id === $lokasimonitoring->user_id;
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\Monitoring;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class MonitoringPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
//
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Monitoring $monitoring): bool
{
//
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
//
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Monitoring $monitoring): bool
{
//
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Monitoring $monitoring): bool
{
//
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Monitoring $monitoring): bool
{
//
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Monitoring $monitoring): bool
{
//
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Providers;
use Carbon\Carbon;
use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\Paginator;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Paginator::useBootstrapFour();
config(['app.locale' => 'id']);
Carbon::setLocale('id');
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Providers;
use App\Models\LokasiMonitoring;
use App\Policies\LokasiPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
protected $policies = [
LokasiMonitoring::class => LokasiPolicy::class,
];
public function boot()
{
$this->registerPolicies();
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View File

@ -0,0 +1,38 @@
<?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 to 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.
*/
public function boot(): void
{
//
}
/**
* Determine if events and listeners should be automatically discovered.
*/
public function shouldDiscoverEvents(): bool
{
return false;
}
}

View File

@ -0,0 +1,40 @@
<?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 your application's "home" route.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/home';
/**
* Define your route model bindings, pattern filters, and other route configuration.
*/
public function boot(): void
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});
}
}

53
website/artisan Normal file
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
website/bootstrap/app.php Normal file
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
website/bootstrap/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

70
website/composer.json Normal file
View File

@ -0,0 +1,70 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"php": "^8.1",
"guzzlehttp/guzzle": "^7.2",
"irazasyed/telegram-bot-sdk": "^3.13",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"laravel/ui": "^4.5",
"pusher/pusher-php-server": "^7.2"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.1",
"sebastian/comparator": "*",
"spatie/laravel-ignition": "^2.0"
},
"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,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}

8530
website/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

188
website/config/app.php Normal file
View File

@ -0,0 +1,188 @@
<?php
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\ServiceProvider;
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'),
/*
|--------------------------------------------------------------------------
| 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' => 'Asia/Jakarta',
/*
|--------------------------------------------------------------------------
| 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' => 'id',
/*
|--------------------------------------------------------------------------
| 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' => 'id_ID',
/*
|--------------------------------------------------------------------------
| 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',
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => 'file',
// 'store' => 'redis',
],
/*
|--------------------------------------------------------------------------
| 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' => ServiceProvider::defaultProviders()->merge([
/*
* 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,
])->toArray(),
/*
|--------------------------------------------------------------------------
| 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' => Facade::defaultAliases()->merge([
// 'Example' => App\Facades\Example::class,
])->toArray(),
];

115
website/config/auth.php Normal file
View File

@ -0,0 +1,115 @@
<?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 expiry 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.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_reset_tokens',
'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,
];

View File

@ -0,0 +1,71 @@
<?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' => 'ap1',
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'useTLS' => true,
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];

111
website/config/cache.php Normal file
View File

@ -0,0 +1,111 @@
<?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'),
'lock_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 the APC, database, memcached, Redis, or DynamoDB cache
| stores there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
];

34
website/config/cors.php Normal file
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' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];

151
website/config/database.php Normal file
View File

@ -0,0 +1,151 @@
<?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,
'search_path' => '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,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| 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'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
];

View File

@ -0,0 +1,76 @@
<?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_DISK', '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 set up for each driver as an example of the required values.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
'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),
'throw' => 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'),
],
];

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,
],
];

131
website/config/logging.php Normal file
View File

@ -0,0 +1,131 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use Monolog\Processor\PsrLogMessageProcessor;
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' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => false,
],
/*
|--------------------------------------------------------------------------
| 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'),
'replace_placeholders' => true,
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
'replace_placeholders' => true,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env('LOG_LEVEL', 'critical'),
'replace_placeholders' => true,
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
'processors' => [PsrLogMessageProcessor::class],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
'facility' => LOG_USER,
'replace_placeholders' => true,
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

125
website/config/mail.php Normal file
View File

@ -0,0 +1,125 @@
<?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", "ses-v2",
| "postmark", "log", "array", "failover"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'url' => env('MAIL_URL'),
'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,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
// 'client' => [
// 'timeout' => 5,
// ],
],
'postmark' => [
'transport' => 'postmark',
// 'client' => [
// 'timeout' => 5,
// ],
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -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'),
],
],
];

109
website/config/queue.php Normal file
View File

@ -0,0 +1,109 @@
<?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,
],
],
/*
|--------------------------------------------------------------------------
| Job Batching
|--------------------------------------------------------------------------
|
| The following options configure the database and table that store job
| batching information. These options can be updated to any database
| connection and table which has been defined by your application.
|
*/
'batching' => [
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'job_batches',
],
/*
|--------------------------------------------------------------------------
| 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',
],
];

View File

@ -0,0 +1,67 @@
<?php
use Laravel\Sanctum\Sanctum;
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',
Sanctum::currentApplicationUrlWithPort()
))),
/*
|--------------------------------------------------------------------------
| 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,
],
];

View File

@ -0,0 +1,34 @@
<?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'),
'scheme' => 'https',
],
'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
website/config/session.php Normal file
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'),
/*
|--------------------------------------------------------------------------
| 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'),
/*
|--------------------------------------------------------------------------
| 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'),
/*
|--------------------------------------------------------------------------
| 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',
];

36
website/config/view.php Normal file
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
website/database/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sqlite*

View File

@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Control>
*/
class ControlFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'voltage' => $this->faker->randomFloat(2, 0, 300),
'power' => $this->faker->randomFloat(2, 0, 900),
'power_factor' => $this->faker->randomFloat(2, 0, 100),
'energy' => $this->faker->randomFloat(2, 0, 900),
'current' => $this->faker->randomFloat(2, 0, 900),
'biaya' => $this->faker->randomFloat(2, 0, 10000),
];
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Monitoring>
*/
class MonitoringFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'username' => fake()->unique()->userName(),
'email' => fake()->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.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
*/
class sensor_dataFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
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.
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('controls', function (Blueprint $table) {
$table->id();
$table->float('voltage');
$table->float('power');
$table->float('power_factor');
$table->float('energy');
$table->float('current');
$table->float('biaya');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('controls');
}
};

View File

@ -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('username')->unique();
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLokasiMonitoringTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('lokasi_monitoring', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->string('nama_lokasi');
$table->text('alamat');
$table->text('deskripsi');
$table->string('blynk_token')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('lokasi_monitoring');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSensorDataTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sensor_data', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('lokasi_id');
$table->float('voltage');
$table->float('power');
$table->float('power_factor');
$table->float('energy');
$table->float('current');
$table->float('biaya');
$table->foreign('lokasi_id')->references('id')->on('lokasi_monitoring')->onDelete('cascade');
$table->timestamp('created_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('sensor_data');
}
}

View File

@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('is_admin')->default(false);
});
}
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('is_admin');
});
}
};

View File

@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('status')->default(true); // Kolom status dengan nilai default true (aktif)
});
}
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('status');
});
}
};

View File

@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class ControlSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\sensor_data;
use App\Models\Control;
use App\Models\User;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
// \App\Models\User::factory(10)->create();
// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
User::create([
'name' => 'Melloz',
'username' => 'mello',
'email' => 'coollanlutfi@gmail.com',
'password' => bcrypt('11111111')
]);
Monitoring::create([
//'notification' => false,
'voltage' => 0,
'power' => 0,
'power_factor' => 0,
'energy' => 0,
'current' => 0,
'biaya' => 0,
]);
Control::factory(24)->create();
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class MonitoringSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class sensor_data extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -0,0 +1,270 @@
-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 28 Des 2023 pada 07.27
-- Versi server: 10.4.27-MariaDB
-- Versi PHP: 8.2.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `water_monitoring`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `controls`
--
CREATE TABLE `controls` (
`id` bigint(20) UNSIGNED NOT NULL,
`temperature` decimal(10,2) NOT NULL,
`turbidity` decimal(10,2) NOT NULL,
`ph` decimal(10,2) NOT NULL,
`jarak` decimal(10,2) NOT NULL,
`pompa_masuk` varchar(255) NOT NULL,
`pompa_keluar` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data untuk tabel `controls`
--
INSERT INTO `controls` (`id`, `temperature`, `turbidity`, `ph`, `jarak`, `pompa_masuk`, `pompa_keluar`, `created_at`, `updated_at`) VALUES
(7, '22.34', '152.80', '8.71', '9.30', 'Hidup', 'Hidup', '2023-12-28 05:51:51', '2023-12-28 05:51:51'),
(8, '38.14', '175.36', '4.75', '6.17', 'Hidup', 'Mati', '2023-12-28 05:51:51', '2023-12-28 05:51:51'),
(16, '37.04', '338.43', '4.96', '9.65', 'Hidup', 'Hidup', '2023-12-28 05:51:51', '2023-12-28 05:51:51'),
(20, '35.47', '155.03', '3.94', '8.20', 'Mati', 'Hidup', '2023-12-28 05:51:51', '2023-12-28 05:51:51'),
(23, '34.02', '225.75', '3.04', '6.83', 'Mati', 'Mati', '2023-12-28 05:51:51', '2023-12-28 05:51:51'),
(24, '37.62', '147.79', '8.53', '8.56', 'Mati', 'Mati', '2023-12-28 05:51:51', '2023-12-28 05:51:51');
-- --------------------------------------------------------
--
-- Struktur dari tabel `failed_jobs`
--
CREATE TABLE `failed_jobs` (
`id` bigint(20) UNSIGNED NOT NULL,
`uuid` varchar(255) NOT NULL,
`connection` text NOT NULL,
`queue` text NOT NULL,
`payload` longtext NOT NULL,
`exception` longtext NOT NULL,
`failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struktur dari tabel `migrations`
--
CREATE TABLE `migrations` (
`id` int(10) UNSIGNED NOT NULL,
`migration` varchar(255) NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data untuk tabel `migrations`
--
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2014_10_12_000000_create_users_table', 1),
(2, '2014_10_12_100000_create_password_reset_tokens_table', 1),
(3, '2019_08_19_000000_create_failed_jobs_table', 1),
(4, '2019_12_14_000001_create_personal_access_tokens_table', 1),
(5, '2023_07_21_151455_create_monitorings_table', 1),
(6, '2023_08_17_041316_create_controls_table', 1);
-- --------------------------------------------------------
--
-- Struktur dari tabel `monitorings`
--
CREATE TABLE `monitorings` (
`id` bigint(20) UNSIGNED NOT NULL,
`notification` tinyint(1) NOT NULL DEFAULT 0,
`temperature` decimal(10,2) NOT NULL,
`turbidity` decimal(10,2) NOT NULL,
`ph` decimal(10,2) NOT NULL,
`jarak` decimal(10,2) NOT NULL,
`pompa_masuk` varchar(255) NOT NULL,
`pompa_keluar` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data untuk tabel `monitorings`
--
INSERT INTO `monitorings` (`id`, `notification`, `temperature`, `turbidity`, `ph`, `jarak`, `pompa_masuk`, `pompa_keluar`, `created_at`, `updated_at`) VALUES
(1, 0, '0.00', '0.00', '0.00', '0.00', 'Hidup', 'Mati', '2023-12-28 05:51:51', '2023-12-28 05:51:51');
-- --------------------------------------------------------
--
-- Struktur dari tabel `password_reset_tokens`
--
CREATE TABLE `password_reset_tokens` (
`email` varchar(255) NOT NULL,
`token` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struktur dari tabel `personal_access_tokens`
--
CREATE TABLE `personal_access_tokens` (
`id` bigint(20) UNSIGNED NOT NULL,
`tokenable_type` varchar(255) NOT NULL,
`tokenable_id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(255) NOT NULL,
`token` varchar(64) NOT NULL,
`abilities` text DEFAULT NULL,
`last_used_at` timestamp NULL DEFAULT NULL,
`expires_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struktur dari tabel `users`
--
CREATE TABLE `users` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(255) NOT NULL,
`remember_token` varchar(100) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data untuk tabel `users`
--
INSERT INTO `users` (`id`, `name`, `username`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
(1, 'Bagus Budi Satoto', 'bagussatoto', 'bagussatoto@gmail.com', NULL, '$2y$10$Ka7XHQqb3Ud1N/ipR9KTsOSFXX8yQHAjr3AMVykxY0.HiXr9JBgyO', NULL, '2023-12-28 05:51:51', '2023-12-28 05:51:51');
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `controls`
--
ALTER TABLE `controls`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `failed_jobs`
--
ALTER TABLE `failed_jobs`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);
--
-- Indeks untuk tabel `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `monitorings`
--
ALTER TABLE `monitorings`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `password_reset_tokens`
--
ALTER TABLE `password_reset_tokens`
ADD PRIMARY KEY (`email`);
--
-- Indeks untuk tabel `personal_access_tokens`
--
ALTER TABLE `personal_access_tokens`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
ADD KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`);
--
-- Indeks untuk tabel `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_username_unique` (`username`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- AUTO_INCREMENT untuk tabel yang dibuang
--
--
-- AUTO_INCREMENT untuk tabel `controls`
--
ALTER TABLE `controls`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
--
-- AUTO_INCREMENT untuk tabel `failed_jobs`
--
ALTER TABLE `failed_jobs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT untuk tabel `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT untuk tabel `monitorings`
--
ALTER TABLE `monitorings`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT untuk tabel `personal_access_tokens`
--
ALTER TABLE `personal_access_tokens`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT untuk tabel `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

13
website/package.json Normal file
View File

@ -0,0 +1,13 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.8.0",
"vite": "^4.0.0"
}
}

31
website/phpunit.xml Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./app</directory>
</include>
</source>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
</phpunit>

21
website/public/.htaccess Normal file
View File

@ -0,0 +1,21 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,270 @@
/********** Template CSS **********/
:root {
--primary: #375E97;
--light: #f3f6f9;
--dark: #191c24;
}
.back-to-top {
position: fixed;
display: none;
right: 45px;
bottom: 45px;
z-index: 99;
}
/*** Spinner ***/
#spinner {
opacity: 0;
visibility: hidden;
transition: opacity 0.5s ease-out, visibility 0s linear 0.5s;
z-index: 99999;
}
#spinner.show {
transition: opacity 0.5s ease-out, visibility 0s linear 0s;
visibility: visible;
opacity: 1;
}
/*** Button ***/
.btn {
transition: 0.5s;
}
.btn.btn-primary {
color: #ffffff;
}
.btn-square {
width: 38px;
height: 38px;
}
.btn-sm-square {
width: 32px;
height: 32px;
}
.btn-lg-square {
width: 48px;
height: 48px;
}
.btn-square,
.btn-sm-square,
.btn-lg-square {
padding: 0;
display: inline-flex;
align-items: center;
justify-content: center;
font-weight: normal;
border-radius: 50px;
}
/*** Layout ***/
.sidebar {
position: fixed;
top: 0;
left: 0;
bottom: 0;
width: 250px;
height: 100vh;
overflow-y: auto;
background: var(--light);
transition: 0.5s;
z-index: 999;
}
.content {
margin-left: 250px;
min-height: 100vh;
background: #ffffff;
transition: 0.5s;
}
@media (min-width: 992px) {
.sidebar {
margin-left: 0;
}
.sidebar.open {
margin-left: -250px;
}
.content {
width: calc(100% - 250px);
}
.content.open {
width: 100%;
margin-left: 0;
}
}
@media (max-width: 991.98px) {
.sidebar {
margin-left: -250px;
}
.sidebar.open {
margin-left: 0;
}
.content {
width: 100%;
margin-left: 0;
}
}
/*** Navbar ***/
.sidebar .navbar .navbar-nav .nav-link {
padding: 7px 20px;
color: var(--dark);
font-weight: 500;
border-left: 3px solid var(--light);
border-radius: 0 30px 30px 0;
outline: none;
}
.sidebar .navbar .navbar-nav .nav-link:hover,
.sidebar .navbar .navbar-nav .nav-link.active {
color: var(--primary);
background: #ffffff;
border-color: var(--primary);
}
.sidebar .navbar .navbar-nav .nav-link i {
width: 40px;
height: 40px;
display: inline-flex;
align-items: center;
justify-content: center;
background: #ffffff;
border-radius: 40px;
}
.sidebar .navbar .navbar-nav .nav-link:hover i,
.sidebar .navbar .navbar-nav .nav-link.active i {
background: var(--light);
}
.sidebar .navbar .dropdown-toggle::after {
position: absolute;
top: 15px;
right: 15px;
border: none;
content: "\f107";
font-family: "Font Awesome 5 Free";
font-weight: 900;
transition: 0.5s;
}
.sidebar .navbar .dropdown-toggle[aria-expanded="true"]::after {
transform: rotate(-180deg);
}
.sidebar .navbar .dropdown-item {
padding-left: 25px;
border-radius: 0 30px 30px 0;
}
.content .navbar .navbar-nav .nav-link {
margin-left: 25px;
padding: 12px 0;
color: var(--dark);
outline: none;
}
.content .navbar .navbar-nav .nav-link:hover,
.content .navbar .navbar-nav .nav-link.active {
color: var(--primary);
}
.content .navbar .sidebar-toggler,
.content .navbar .navbar-nav .nav-link i {
width: 40px;
height: 40px;
display: inline-flex;
align-items: center;
justify-content: center;
background: #ffffff;
border-radius: 40px;
}
.content .navbar .dropdown-toggle::after {
margin-left: 6px;
vertical-align: middle;
border: none;
content: "\f107";
font-family: "Font Awesome 5 Free";
font-weight: 900;
transition: 0.5s;
}
.content .navbar .dropdown-toggle[aria-expanded="true"]::after {
transform: rotate(-180deg);
}
@media (max-width: 575.98px) {
.content .navbar .navbar-nav .nav-link {
margin-left: 15px;
}
}
/*** Date Picker ***/
.bootstrap-datetimepicker-widget.bottom {
top: auto !important;
}
.bootstrap-datetimepicker-widget .table * {
border-bottom-width: 0px;
}
.bootstrap-datetimepicker-widget .table th {
font-weight: 500;
}
.bootstrap-datetimepicker-widget.dropdown-menu {
padding: 10px;
border-radius: 2px;
}
.bootstrap-datetimepicker-widget table td.active,
.bootstrap-datetimepicker-widget table td.active:hover {
background: var(--primary);
}
.bootstrap-datetimepicker-widget table td.today::before {
border-bottom-color: var(--primary);
}
/*** Testimonial ***/
.progress .progress-bar {
width: 0px;
transition: 2s;
}
/*** Testimonial ***/
.testimonial-carousel .owl-dots {
margin-top: 24px;
display: flex;
align-items: flex-end;
justify-content: center;
}
.testimonial-carousel .owl-dot {
position: relative;
display: inline-block;
margin: 0 5px;
width: 15px;
height: 15px;
border: 5px solid var(--primary);
border-radius: 15px;
transition: 0.5s;
}
.testimonial-carousel .owl-dot.active {
background: var(--dark);
border-color: var(--primary);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -0,0 +1,207 @@
(function ($) {
"use strict";
// Spinner
var spinner = function () {
setTimeout(function () {
if ($('#spinner').length > 0) {
$('#spinner').removeClass('show');
}
}, 1);
};
spinner();
// Back to top button
$(window).scroll(function () {
if ($(this).scrollTop() > 300) {
$('.back-to-top').fadeIn('slow');
} else {
$('.back-to-top').fadeOut('slow');
}
});
$('.back-to-top').click(function () {
$('html, body').animate({scrollTop: 0}, 1500, 'easeInOutExpo');
return false;
});
// Sidebar Toggler
$('.sidebar-toggler').click(function () {
$('.sidebar, .content').toggleClass("open");
return false;
});
// Progress Bar
$('.pg-bar').waypoint(function () {
$('.progress .progress-bar').each(function () {
$(this).css("width", $(this).attr("aria-valuenow") + '%');
});
}, {offset: '80%'});
// Calender
$('#calender').datetimepicker({
inline: true,
format: 'L'
});
// Testimonials carousel
$(".testimonial-carousel").owlCarousel({
autoplay: true,
smartSpeed: 1000,
items: 1,
dots: true,
loop: true,
nav : false
});
// Worldwide Sales Chart
var ctx1 = $("#worldwide-sales").get(0).getContext("2d");
var myChart1 = new Chart(ctx1, {
type: "bar",
data: {
labels: ["2016", "2017", "2018", "2019", "2020", "2021", "2022"],
datasets: [{
label: "USA",
data: [15, 30, 55, 65, 60, 80, 95],
backgroundColor: "rgba(0, 156, 255, .7)"
},
{
label: "UK",
data: [8, 35, 40, 60, 70, 55, 75],
backgroundColor: "rgba(0, 156, 255, .5)"
},
{
label: "AU",
data: [12, 25, 45, 55, 65, 70, 60],
backgroundColor: "rgba(0, 156, 255, .3)"
}
]
},
options: {
responsive: true
}
});
// Salse & Revenue Chart
var ctx2 = $("#salse-revenue").get(0).getContext("2d");
var myChart2 = new Chart(ctx2, {
type: "line",
data: {
labels: ["2016", "2017", "2018", "2019", "2020", "2021", "2022"],
datasets: [{
label: "Salse",
data: [15, 30, 55, 45, 70, 65, 85],
backgroundColor: "rgba(0, 156, 255, .5)",
fill: true
},
{
label: "Revenue",
data: [99, 135, 170, 130, 190, 180, 270],
backgroundColor: "rgba(0, 156, 255, .3)",
fill: true
}
]
},
options: {
responsive: true
}
});
// Single Line Chart
var ctx3 = $("#line-chart").get(0).getContext("2d");
var myChart3 = new Chart(ctx3, {
type: "line",
data: {
labels: [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],
datasets: [{
label: "Salse",
fill: false,
backgroundColor: "rgba(0, 156, 255, .3)",
data: [7, 8, 8, 9, 9, 9, 10, 11, 14, 14, 15]
}]
},
options: {
responsive: true
}
});
// Single Bar Chart
var ctx4 = $("#bar-chart").get(0).getContext("2d");
var myChart4 = new Chart(ctx4, {
type: "bar",
data: {
labels: ["Italy", "France", "Spain", "USA", "Argentina"],
datasets: [{
backgroundColor: [
"rgba(0, 156, 255, .7)",
"rgba(0, 156, 255, .6)",
"rgba(0, 156, 255, .5)",
"rgba(0, 156, 255, .4)",
"rgba(0, 156, 255, .3)"
],
data: [55, 49, 44, 24, 15]
}]
},
options: {
responsive: true
}
});
// Pie Chart
var ctx5 = $("#pie-chart").get(0).getContext("2d");
var myChart5 = new Chart(ctx5, {
type: "pie",
data: {
labels: ["Italy", "France", "Spain", "USA", "Argentina"],
datasets: [{
backgroundColor: [
"rgba(0, 156, 255, .7)",
"rgba(0, 156, 255, .6)",
"rgba(0, 156, 255, .5)",
"rgba(0, 156, 255, .4)",
"rgba(0, 156, 255, .3)"
],
data: [55, 49, 44, 24, 15]
}]
},
options: {
responsive: true
}
});
// Doughnut Chart
var ctx6 = $("#doughnut-chart").get(0).getContext("2d");
var myChart6 = new Chart(ctx6, {
type: "doughnut",
data: {
labels: ["Italy", "France", "Spain", "USA", "Argentina"],
datasets: [{
backgroundColor: [
"rgba(0, 156, 255, .7)",
"rgba(0, 156, 255, .6)",
"rgba(0, 156, 255, .5)",
"rgba(0, 156, 255, .4)",
"rgba(0, 156, 255, .3)"
],
data: [55, 49, 44, 24, 15]
}]
},
options: {
responsive: true
}
});
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,168 @@
/*
* jQuery Easing v1.4.1 - http://gsgd.co.uk/sandbox/jquery/easing/
* Open source under the BSD License.
* Copyright © 2008 George McGinley Smith
* All rights reserved.
* https://raw.github.com/gdsmith/jquery-easing/master/LICENSE
*/
(function (factory) {
if (typeof define === "function" && define.amd) {
define(['jquery'], function ($) {
return factory($);
});
} else if (typeof module === "object" && typeof module.exports === "object") {
exports = factory(require('jquery'));
} else {
factory(jQuery);
}
})(function($){
// Preserve the original jQuery "swing" easing as "jswing"
if (typeof $.easing !== 'undefined') {
$.easing['jswing'] = $.easing['swing'];
}
var pow = Math.pow,
sqrt = Math.sqrt,
sin = Math.sin,
cos = Math.cos,
PI = Math.PI,
c1 = 1.70158,
c2 = c1 * 1.525,
c3 = c1 + 1,
c4 = ( 2 * PI ) / 3,
c5 = ( 2 * PI ) / 4.5;
// x is the fraction of animation progress, in the range 0..1
function bounceOut(x) {
var n1 = 7.5625,
d1 = 2.75;
if ( x < 1/d1 ) {
return n1*x*x;
} else if ( x < 2/d1 ) {
return n1*(x-=(1.5/d1))*x + .75;
} else if ( x < 2.5/d1 ) {
return n1*(x-=(2.25/d1))*x + .9375;
} else {
return n1*(x-=(2.625/d1))*x + .984375;
}
}
$.extend( $.easing,
{
def: 'easeOutQuad',
swing: function (x) {
return $.easing[$.easing.def](x);
},
easeInQuad: function (x) {
return x * x;
},
easeOutQuad: function (x) {
return 1 - ( 1 - x ) * ( 1 - x );
},
easeInOutQuad: function (x) {
return x < 0.5 ?
2 * x * x :
1 - pow( -2 * x + 2, 2 ) / 2;
},
easeInCubic: function (x) {
return x * x * x;
},
easeOutCubic: function (x) {
return 1 - pow( 1 - x, 3 );
},
easeInOutCubic: function (x) {
return x < 0.5 ?
4 * x * x * x :
1 - pow( -2 * x + 2, 3 ) / 2;
},
easeInQuart: function (x) {
return x * x * x * x;
},
easeOutQuart: function (x) {
return 1 - pow( 1 - x, 4 );
},
easeInOutQuart: function (x) {
return x < 0.5 ?
8 * x * x * x * x :
1 - pow( -2 * x + 2, 4 ) / 2;
},
easeInQuint: function (x) {
return x * x * x * x * x;
},
easeOutQuint: function (x) {
return 1 - pow( 1 - x, 5 );
},
easeInOutQuint: function (x) {
return x < 0.5 ?
16 * x * x * x * x * x :
1 - pow( -2 * x + 2, 5 ) / 2;
},
easeInSine: function (x) {
return 1 - cos( x * PI/2 );
},
easeOutSine: function (x) {
return sin( x * PI/2 );
},
easeInOutSine: function (x) {
return -( cos( PI * x ) - 1 ) / 2;
},
easeInExpo: function (x) {
return x === 0 ? 0 : pow( 2, 10 * x - 10 );
},
easeOutExpo: function (x) {
return x === 1 ? 1 : 1 - pow( 2, -10 * x );
},
easeInOutExpo: function (x) {
return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ?
pow( 2, 20 * x - 10 ) / 2 :
( 2 - pow( 2, -20 * x + 10 ) ) / 2;
},
easeInCirc: function (x) {
return 1 - sqrt( 1 - pow( x, 2 ) );
},
easeOutCirc: function (x) {
return sqrt( 1 - pow( x - 1, 2 ) );
},
easeInOutCirc: function (x) {
return x < 0.5 ?
( 1 - sqrt( 1 - pow( 2 * x, 2 ) ) ) / 2 :
( sqrt( 1 - pow( -2 * x + 2, 2 ) ) + 1 ) / 2;
},
easeInElastic: function (x) {
return x === 0 ? 0 : x === 1 ? 1 :
-pow( 2, 10 * x - 10 ) * sin( ( x * 10 - 10.75 ) * c4 );
},
easeOutElastic: function (x) {
return x === 0 ? 0 : x === 1 ? 1 :
pow( 2, -10 * x ) * sin( ( x * 10 - 0.75 ) * c4 ) + 1;
},
easeInOutElastic: function (x) {
return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ?
-( pow( 2, 20 * x - 10 ) * sin( ( 20 * x - 11.125 ) * c5 )) / 2 :
pow( 2, -20 * x + 10 ) * sin( ( 20 * x - 11.125 ) * c5 ) / 2 + 1;
},
easeInBack: function (x) {
return c3 * x * x * x - c1 * x * x;
},
easeOutBack: function (x) {
return 1 + c3 * pow( x - 1, 3 ) + c1 * pow( x - 1, 2 );
},
easeInOutBack: function (x) {
return x < 0.5 ?
( pow( 2 * x, 2 ) * ( ( c2 + 1 ) * 2 * x - c2 ) ) / 2 :
( pow( 2 * x - 2, 2 ) *( ( c2 + 1 ) * ( x * 2 - 2 ) + c2 ) + 2 ) / 2;
},
easeInBounce: function (x) {
return 1 - bounceOut( 1 - x );
},
easeOutBounce: bounceOut,
easeInOutBounce: function (x) {
return x < 0.5 ?
( 1 - bounceOut( 1 - 2 * x ) ) / 2 :
( 1 + bounceOut( 2 * x - 1 ) ) / 2;
}
});
});

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