first commit

This commit is contained in:
Hifni Dana Abdillah 2024-07-29 10:30:52 +07:00
parent b90f00ff00
commit ed35372631
149 changed files with 19231 additions and 0 deletions

18
.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

64
.env.example Normal file
View File

@ -0,0 +1,64 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
CACHE_STORE=database
CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
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
VITE_APP_NAME="${APP_NAME}"

11
.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
.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

View File

@ -0,0 +1,46 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
// Daftarkan command Anda di sini
\App\Console\Commands\MqttListenCommand::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// Contoh command lainnya
// $schedule->command('inspire')->hourly();
// Tambahkan schedule untuk mqtt:subscribe
$schedule->command('mqtt:subscribe')->everyMinute();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Services\MqttService;
class MqttListenCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'mqtt:listen';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Listen for MQTT messages';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$mqtt = new MqttService();
$mqtt->subscribe('topic/nutrisi', function (string $topic, string $message) {
// Proses pesan yang diterima
\Log::info("Pesan dari $topic: $message");
// Anda bisa menyimpan pesan ke database atau melakukan tindakan lainnya
});
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use PhpMqtt\Client\MqttClient;
use Illuminate\Support\Facades\Cache;
class SubscribeToMQTT extends Command
{
protected $signature = 'mqtt:subscribe';
protected $description = 'Subscribe to MQTT topic';
public function handle()
{
$server = '192.168.0.111'; // Ganti dengan server MQTT Anda
$port = 1883;
$clientId = 'laravel-mqtt-client';
$mqtt = new MqttClient($server, $port, $clientId);
$mqtt->connect();
$mqtt->subscribe('ultrasonic', function (string $topic, string $message) {
Cache::put('ultrasonic_data', $message, 60);
}, 0);
$mqtt->loop(true);
$mqtt->disconnect();
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
}

View File

@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/home';
}

View File

@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Blog;
class BlogController extends Controller
{
public function index()
{
$blogs = Blog::all();
return view('blog.index', compact('blogs'));
}
public function show($id)
{
$blog = Blog::findOrFail($id);
return view('blog.show', compact('blog'));
}
public function create()
{
return view('blog.create');
}
public function store(Request $request)
{
// Validasi data
$request->validate([
'title' => 'required|string|max:255',
'content' => 'required|string',
'image' => 'image|mimes:jpeg,png,jpg,gif|max:2048', // Menambahkan validasi untuk gambar
]);
// Simpan gambar
$imageName = null;
if ($request->hasFile('image')) {
$imageName = time().'.'.$request->image->extension();
$request->image->move(public_path('images'), $imageName);
}
// Simpan blog baru ke dalam database dengan menambahkan informasi pengguna saat ini sebagai author
$blog = new Blog([
'title' => $request->title,
'content' => $request->content,
'author' => auth()->user()->name, // Menggunakan nama pengguna yang saat ini masuk sebagai author
'image' => $imageName, // Menyimpan nama file gambar ke dalam basis data
]);
$blog->save();
// Redirect ke halaman lain dengan pesan sukses
return redirect()->route('blog.index')->with('success', 'Blog created successfully!');
}
}

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,11 @@
<?php
// app/Http/Controllers/DeviceController.php
namespace App\Http\Controllers;
class DeviceController extends Controller
{
public function index()
{
return view('Device');
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use App\Models\Waterflow1;
use App\Models\Waterflow2;
use App\Models\Tds;
use App\Models\Ultrasonik;
class MonitoringController extends Controller
{
public function index()
{
// Mengambil data dari tabel 'waterflow1'
$waterflow1Data = Waterflow1::all();
// Mengambil data dari tabel 'waterflow2'
$waterflow2Data = Waterflow2::all();
// Mengambil data dari tabel 'tds'
$tdsData = Tds::all();
// Mengambil data dari tabel 'ultrasonik'
$ultrasonikData = Ultrasonik::all();
return view('monitoring', compact('waterflow1Data', 'waterflow2Data', 'tdsData', 'ultrasonikData'));
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Waterflow1;
use App\Models\Waterflow2;
use App\Models\Tds;
use App\Models\Ultrasonik;
class RiwayatController extends Controller
{
public function index()
{
// Mengambil data dari tabel 'waterflow1'
$waterflow1Data = Waterflow1::all();
// Mengambil data dari tabel 'waterflow2'
$waterflow2Data = Waterflow2::all();
// Mengambil data dari tabel 'tds'
$tdsData = Tds::all();
// Mengambil data dari tabel 'ultrasonik'
$ultrasonikData = Ultrasonik::all();
return view('riwayat', compact('waterflow1Data', 'waterflow2Data', 'tdsData', 'ultrasonikData'));
}
}

View File

@ -0,0 +1,26 @@
<?php
// app/Http/Controllers/SensorDataController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\SensorData;
class SensorDataController extends Controller
{
public function store(Request $request)
{
// Validasi request
$request->validate([
'value' => 'required|integer',
]);
// Simpan data ke database
$data = SensorData::create([
'value' => $request->value,
]);
return response()->json(['message' => 'Data berhasil disimpan'], 200);
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class TentangController extends Controller
{
public function index()
{
// Mengembalikan tampilan (view) "tentang.blade.php"
return view('tentang');
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Waterflow2Controller extends Controller
{
//
}

2
app/Libraries/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/vendor/
.idea

20
app/Libraries/LICENSE Normal file
View File

@ -0,0 +1,20 @@
Copyright (c) 2010 Blue Rhinos Consulting | Andrew Milsted
andrew@bluerhinos.co.uk | http://www.bluerhinos.co.uk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

15
app/Libraries/README.md Normal file
View File

@ -0,0 +1,15 @@
**2020 Update**
I am restarting the project so watch this space
Blue Rhinos Consulting
Andrew Milsted | andrew@bluerhinos.co.uk | http://www.bluerhinos.co.uk | @bluerhinos
A simple php class to connect/publish/subscribe to an MQTT broker
Documentation: Coming Soon
Source: http://github.com/bluerhinos/phpMQTT
To install via Composer
-----------------------
`composer require bluerhinos/phpmqtt=@dev`

View File

@ -0,0 +1,21 @@
{
"name": "bluerhinos/phpmqtt",
"description": "Simple MQTT Class",
"license": "BSD",
"type": "library",
"authors": [
{
"name": "Andrew Milsted",
"email": "andrew@bluerhinos.co.uk"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=7.2"
},
"autoload": {
"psr-4": {
"Bluerhinos\\": "./"
}
}
}

View File

@ -0,0 +1,44 @@
# Output example
For info on MQTT: https://mntolia.com/fundamentals-mqtt/#4_Advantages_of_MQTT_for_IoT_over_HTTP_UDP
> Before running each file be sure to review the four connection parameters in the headers.
subscribe.php
--
This example is to demonstrate using MQTT for a long-running script that will wait for subscribed topics.
This script is not suitable to be run as web requests, instead should be run on the commandline.
Let `subscribe.php` listening the broker:
```console
$ php subscribe.php
Msg Recieved: Fri, 13 Jan 2017 01:58:23 +0000
Topic: bluerhinos/phpMQTT/examples/publishtest
Hello World! at Fri, 13 Jan 2017 01:58:23 +0000
Msg Recieved: Fri, 13 Jan 2017 01:58:35 +0000
Topic: bluerhinos/phpMQTT/examples/publishtest
Hello World! at Fri, 13 Jan 2017 01:58:35 +0000
^C
```
publish.php
---
This example will publish a message to a topic.
The results shown above corresponds to publisher's two actions:
```console
$ php publish.php
$ php publish.php
```
When run as a web request you it is ok to just `$mqtt->connect()`, `$mqtt->publish()` and `$mqtt->close()`.
If it is being run as long-running command line script you should run `$mqtt->proc()` regularly in order maintain the connection with the broker.
subscribeAndWaitForMessage.php
--
In order to use this library to display messages on a website you can use `$mqtt->subscribeAndWaitForMessage()`, this will subscribe to a topic and then wait for, and return the message.
If you want messages to appear instantly, you should use retained messages (https://mntolia.com/mqtt-retained-messages-explained-example/)

View File

@ -0,0 +1,18 @@
<?php
require('../phpMQTT.php');
$server = 'localhost'; // change if necessary
$port = 1883; // change if necessary
$username = ''; // set your username
$password = ''; // set your password
$client_id = 'phpMQTT-publisher'; // make sure this is unique for connecting to sever - you could use uniqid()
$mqtt = new Bluerhinos\phpMQTT($server, $port, $client_id);
if ($mqtt->connect(true, NULL, $username, $password)) {
$mqtt->publish('bluerhinos/phpMQTT/examples/publishtest', 'Hello World! at ' . date('r'), 0, false);
$mqtt->close();
} else {
echo "Time out!\n";
}

View File

@ -0,0 +1,32 @@
<?php
require('../phpMQTT.php');
$server = 'localhost'; // change if necessary
$port = 1883; // change if necessary
$username = ''; // set your username
$password = ''; // set your password
$client_id = 'phpMQTT-subscriber'; // make sure this is unique for connecting to sever - you could use uniqid()
$mqtt = new Bluerhinos\phpMQTT($server, $port, $client_id);
if(!$mqtt->connect(true, NULL, $username, $password)) {
exit(1);
}
$mqtt->debug = true;
$topics['bluerhinos/phpMQTT/examples/publishtest'] = array('qos' => 0, 'function' => 'procMsg');
$mqtt->subscribe($topics, 0);
while($mqtt->proc()) {
}
$mqtt->close();
function procMsg($topic, $msg){
echo 'Msg Recieved: ' . date('r') . "\n";
echo "Topic: {$topic}\n\n";
echo "\t$msg\n\n";
}

View File

@ -0,0 +1,18 @@
<?php
require('../phpMQTT.php');
$server = 'localhost'; // change if necessary
$port = 1883; // change if necessary
$username = ''; // set your username
$password = ''; // set your password
$client_id = 'phpMQTT-subscribe-msg'; // make sure this is unique for connecting to sever - you could use uniqid()
$mqtt = new Bluerhinos\phpMQTT($server, $port, $client_id);
if(!$mqtt->connect(true, NULL, $username, $password)) {
exit(1);
}
echo $mqtt->subscribeAndWaitForMessage('bluerhinos/phpMQTT/examples/publishtest', 0);
$mqtt->close();

33
app/Libraries/phpMQTT.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace App\Libraries;
class phpMQTT {
private $server;
private $port;
private $client_id;
public function __construct($server, $port, $client_id) {
$this->server = $server;
$this->port = $port;
$this->client_id = $client_id;
}
public function connect() {
// Implementasi koneksi ke broker MQTT
// Kembalikan true jika berhasil, false jika gagal
// Contoh sederhana:
return true; // atau false jika gagal
}
public function publish($topic, $content) {
// Implementasi untuk mempublikasikan pesan ke broker MQTT
}
public function subscribe($topic, $callback) {
// Implementasi untuk berlangganan ke topik MQTT
}
public function close() {
// Implementasi untuk menutup koneksi
}
}

23
app/Models/Coba.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Coba extends Model
{
use HasFactory;
// Nama tabel yang dihubungkan dengan model ini
protected $table = 'waterflow1';
// Primary key dari tabel ini
protected $primaryKey = 'id'; // Jika primary key Anda bukan 'id', ubah properti ini
// Menonaktifkan timestamps jika tabel tidak memiliki kolom created_at dan updated_at
public $timestamps = true; // Set to false if the table doesn't have these columns
// Daftar kolom yang boleh diisi secara massal
protected $fillable = ['arus', 'total', 'tanggal']; // Tambahkan kolom 'tanggal' ke dalam fillable
}

10
app/Models/Device.php Normal file
View File

@ -0,0 +1,10 @@
<?php
// app/Models/Device.php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Device extends Model
{
// Tidak perlu menentukan apa pun di sini karena tidak ada interaksi dengan basis data
}

23
app/Models/Tds.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Tds extends Model
{
use HasFactory;
// Nama tabel yang dihubungkan dengan model ini
protected $table = 'tds';
// Primary key dari tabel ini
protected $primaryKey = 'id';
// Menonaktifkan timestamps jika tabel tidak memiliki kolom created_at dan updated_at
public $timestamps = true;
// Daftar kolom yang boleh diisi secara massal
protected $fillable = ['tds', 'tanggal'];
}

23
app/Models/Ultrasonik.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Ultrasonik extends Model
{
use HasFactory;
// Nama tabel yang dihubungkan dengan model ini
protected $table = 'ultrasonik';
// Primary key dari tabel ini
protected $primaryKey = 'id';
// Menonaktifkan timestamps jika tabel tidak memiliki kolom created_at dan updated_at
public $timestamps = true;
// Daftar kolom yang boleh diisi secara massal
protected $fillable = ['ultrasonik', 'tanggal'];
}

47
app/Models/User.php Normal file
View File

@ -0,0 +1,47 @@
<?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;
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}

23
app/Models/Waterflow1.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Waterflow1 extends Model
{
use HasFactory;
// Nama tabel yang dihubungkan dengan model ini
protected $table = 'waterflow1';
// Primary key dari tabel ini
protected $primaryKey = 'id';
// Menonaktifkan timestamps jika tabel tidak memiliki kolom created_at dan updated_at
public $timestamps = false;
// Daftar kolom yang boleh diisi secara massal
protected $fillable = ['arus', 'total', 'tanggal'];
}

23
app/Models/Waterflow2.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Waterflow2 extends Model
{
use HasFactory;
// Nama tabel yang dihubungkan dengan model ini
protected $table = 'waterflow2';
// Primary key dari tabel ini
protected $primaryKey = 'id';
// Menonaktifkan timestamps jika tabel tidak memiliki kolom created_at dan updated_at
public $timestamps = false;
// Daftar kolom yang boleh diisi secara massal
protected $fillable = ['arus', 'total', 'tanggal'];
}

11
app/Models/blog.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Blog extends Model
{
protected $fillable = ['title', 'content', 'author', 'image'];
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class MQTTServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}
/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Services;
use Bluerhinos\phpMQTT;
class MqttService
{
protected $mqtt;
public function __construct()
{
$host = config('mqtt.host');
$port = config('mqtt.port');
$username = config('mqtt.username');
$password = config('mqtt.password');
$client_id = config('mqtt.client_id');
$this->mqtt = new phpMQTT($host, $port, $client_id);
if ($username && $password) {
if (!$this->mqtt->connect(true, null, $username, $password)) {
exit(1);
}
} else {
if (!$this->mqtt->connect(true, null)) {
exit(1);
}
}
}
public function subscribe($topic, $callback)
{
$this->mqtt->subscribe([$topic => ["qos" => 0, "function" => $callback]]);
while ($this->mqtt->proc()) {}
$this->mqtt->close();
}
}

15
artisan Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Input\ArgvInput;
define('LARAVEL_START', microtime(true));
// Register the Composer autoloader...
require __DIR__.'/vendor/autoload.php';
// Bootstrap Laravel and handle the command...
$status = (require_once __DIR__.'/bootstrap/app.php')
->handleCommand(new ArgvInput);
exit($status);

18
bootstrap/app.php Normal file
View File

@ -0,0 +1,18 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();

2
bootstrap/cache/.gitignore vendored Normal file
View File

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

6
bootstrap/providers.php Normal file
View File

@ -0,0 +1,6 @@
<?php
return [
App\Providers\AppServiceProvider::class,
App\Providers\MQTTServiceProvider::class,
];

71
composer.json Normal file
View File

@ -0,0 +1,71 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"php": "^8.2",
"bluerhinos/phpmqtt": "^1.0",
"consoletvs/charts": "^6.7",
"laravel/framework": "^11.0",
"laravel/tinker": "^2.9",
"laravel/ui": "^4.5",
"php-mqtt/client": "^2.1"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pint": "^1.13",
"laravel/sail": "^1.26",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.0",
"phpunit/phpunit": "^11.0.1",
"spatie/laravel-ignition": "^2.4"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/",
"App\\Libraries\\": "app/Libraries/"
}
},
"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",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --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
}

8466
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

126
config/app.php Normal file
View File

@ -0,0 +1,126 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application, which will be used when the
| framework needs to place the application's name in a notification or
| other UI elements where an application name needs to be displayed.
|
*/
'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
| the application so that it's available within Artisan commands.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => env('APP_TIMEZONE', 'UTC'),
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by Laravel's translation / localization methods. This option can be
| set to any locale for which you plan to have translation strings.
|
*/
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is utilized by Laravel's encryption services and should be set
| to a random, 32 character string to ensure that all encrypted values
| are secure. You should do this prior to deploying the application.
|
*/
'cipher' => 'AES-256-CBC',
'key' => env('APP_KEY'),
'previous_keys' => [
...array_filter(
explode(',', env('APP_PREVIOUS_KEYS', ''))
),
],
/*
|--------------------------------------------------------------------------
| 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' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],
];

115
config/auth.php Normal file
View File

@ -0,0 +1,115 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option defines the default authentication "guard" and password
| reset "broker" for your application. You may change these values
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => env('AUTH_GUARD', 'web'),
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| which utilizes session storage plus the Eloquent user provider.
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| If you have multiple user tables or models you may configure multiple
| providers to represent the model / table. These providers may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', App\Models\User::class),
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| These configuration options specify the behavior of Laravel's password
| reset functionality, including the table utilized for token storage
| and the user provider that is invoked to actually retrieve users.
|
| 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' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| window expires and users are asked to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
];

107
config/cache.php Normal file
View File

@ -0,0 +1,107 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache store that will be used by the
| framework. This connection is utilized if another isn't explicitly
| specified when running a cache operation inside the application.
|
*/
'default' => env('CACHE_STORE', 'database'),
/*
|--------------------------------------------------------------------------
| 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' => [
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'table' => env('DB_CACHE_TABLE', 'cache'),
'connection' => env('DB_CACHE_CONNECTION'),
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
],
'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' => env('REDIS_CACHE_CONNECTION', 'cache'),
'lock_connection' => env('REDIS_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, and 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_'),
];

15
config/charts.php Normal file
View File

@ -0,0 +1,15 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default library used in charts.
|--------------------------------------------------------------------------
|
| This value is used as the default chart library used when creating
| any chart in the command line. Feel free to modify it or set it up
| while creating the chart to ignore this value.
|
*/
'default_library' => 'Chartjs',
];

170
config/database.php Normal file
View File

@ -0,0 +1,170 @@
<?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 database operations. This is
| the connection which will be utilized unless another connection
| is explicitly specified when you execute a query / statement.
|
*/
'default' => env('DB_CONNECTION', 'sqlite'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Below are all of the database connections defined for your application.
| An example configuration is provided for each database system which
| is supported by Laravel. You're free to add / remove connections.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_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'),
]) : [],
],
'mariadb' => [
'driver' => 'mariadb',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_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('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DB_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_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 on the database.
|
*/
'migrations' => [
'table' => 'migrations',
'update_date_on_publish' => true,
],
/*
|--------------------------------------------------------------------------
| 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 Memcached. You may define your connection settings here.
|
*/
'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'),
],
],
];

76
config/filesystems.php Normal file
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 for file storage.
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Below you may configure as many filesystem disks as necessary, and you
| may even configure multiple disks for the same driver. Examples for
| most supported storage drivers are configured here for reference.
|
| 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'),
],
];

132
config/logging.php Normal file
View File

@ -0,0 +1,132 @@
<?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 is utilized to write
| messages to your logs. The value provided here should match one of
| the channels present in the list of "channels" configured below.
|
*/
'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' => env('LOG_DEPRECATIONS_TRACE', false),
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Laravel
| utilizes the Monolog PHP logging library, which includes a variety
| of powerful log handlers and formatters that you're free to use.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog", "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => explode(',', env('LOG_STACK', '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' => env('LOG_DAILY_DAYS', 14),
'replace_placeholders' => true,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
'emoji' => env('LOG_SLACK_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' => env('LOG_SYSLOG_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'),
],
],
];

111
config/mail.php Normal file
View File

@ -0,0 +1,111 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send all email
| messages unless another mailer is explicitly specified when sending
| the message. All additional mailers can be configured within the
| "mailers" array. Examples of each type of mailer are provided.
|
*/
'default' => env('MAIL_MAILER', 'log'),
/*
|--------------------------------------------------------------------------
| 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 that can be used
| when delivering an email. You may specify which one you're using for
| your mailers below. You may also add additional mailers if needed.
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
| "postmark", "log", "array", "failover", "roundrobin"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', '127.0.0.1'),
'port' => env('MAIL_PORT', 2525),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'ses' => [
'transport' => 'ses',
],
'postmark' => [
'transport' => 'postmark',
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
// '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',
],
],
'roundrobin' => [
'transport' => 'roundrobin',
'mailers' => [
'ses',
'postmark',
],
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all emails 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 emails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
];

9
config/mqtt.php Normal file
View File

@ -0,0 +1,9 @@
<?php
return [
'host' => env('MQTT_HOST', '192.168.123.153'),
'port' => env('MQTT_PORT', 1883),
'username' => env('MQTT_USERNAME', null), // atau hapus baris ini
'password' => env('MQTT_PASSWORD', null), // atau hapus baris ini
'client_id' => env('MQTT_CLIENT_ID', 'laravel-client')
];

112
config/queue.php Normal file
View File

@ -0,0 +1,112 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue supports a variety of backends via a single, unified
| API, giving you convenient access to each backend using identical
| syntax for each. The default queue connection is defined below.
|
*/
'default' => env('QUEUE_CONNECTION', 'database'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection options for every queue backend
| used by your application. An example configuration is provided for
| each backend supported by Laravel. You're also free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'connection' => env('DB_QUEUE_CONNECTION'),
'table' => env('DB_QUEUE_TABLE', 'jobs'),
'queue' => env('DB_QUEUE', 'default'),
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
'queue' => env('BEANSTALKD_QUEUE', 'default'),
'retry_after' => (int) env('BEANSTALKD_QUEUE_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' => env('REDIS_QUEUE_CONNECTION', 'default'),
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => (int) env('REDIS_QUEUE_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', 'sqlite'),
'table' => 'job_batches',
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control how and where failed jobs are stored. Laravel ships with
| support for storing failed jobs in a simple file or in a database.
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'failed_jobs',
],
];

34
config/services.php Normal file
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.
|
*/
'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'),
],
'slack' => [
'notifications' => [
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
],
],
];

217
config/session.php Normal file
View File

@ -0,0 +1,217 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option determines the default session driver that is utilized for
| incoming requests. Laravel supports a variety of storage options to
| persist session data. Database storage is a great default choice.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
| 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 expire immediately when the browser is closed then you may
| indicate that via the expire_on_close configuration option.
|
*/
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it's stored. All encryption is performed
| automatically by Laravel and you may use the session like normal.
|
*/
'encrypt' => env('SESSION_ENCRYPT', false),
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When utilizing the "file" session driver, the session files are placed
| on disk. The default storage location is defined here; however, you
| are free to provide another location where they should be stored.
|
*/
'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 to
| be used to store sessions. Of course, a sensible default is defined
| for you; however, you're welcome to change this to another table.
|
*/
'table' => env('SESSION_TABLE', 'sessions'),
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using one of the framework's cache driven session backends, you may
| define the cache store which should be used to store the session data
| between requests. This must match one of your defined 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 session cookie that is created by
| the framework. Typically, you should not need to change this value
| since doing so does not grant a meaningful security improvement.
|
*/
'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're free to change this when necessary.
|
*/
'path' => env('SESSION_PATH', '/'),
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| This value determines the domain and subdomains the session cookie is
| available to. By default, the cookie will be available to the root
| domain and all subdomains. Typically, this shouldn't be changed.
|
*/
'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. It's unlikely you should disable this option.
|
*/
'http_only' => env('SESSION_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" to permit secure cross-site requests.
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => env('SESSION_SAME_SITE', 'lax'),
/*
|--------------------------------------------------------------------------
| Partitioned Cookies
|--------------------------------------------------------------------------
|
| Setting this value to true will tie the cookie to the top-level site for
| a cross-site context. Partitioned cookies are accepted by the browser
| when flagged "secure" and the Same-Site attribute is set to "none".
|
*/
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
];

1
database/.gitignore vendored Normal file
View File

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

View File

@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('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\Waterflow2>
*/
class Waterflow2Factory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,49 @@
<?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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@ -0,0 +1,35 @@
<?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('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@ -0,0 +1,57 @@
<?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('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
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('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBlogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('blogs', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('content');
$table->string('author');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('blogs');
}
}

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
// database/migrations/xxxx_xx_xx_create_sensor_data_table.php
public function up()
{
Schema::create('sensor_data', function (Blueprint $table) {
$table->id();
$table->integer('value');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sensor_data');
}
};

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddImageToBlogsTable extends Migration
{
public function up()
{
Schema::table('blogs', function (Blueprint $table) {
$table->string('image')->nullable(); // tambahkan kolom 'image' ke tabel 'blogs'
});
}
public function down()
{
Schema::table('blogs', function (Blueprint $table) {
$table->dropColumn('image'); // hapus kolom 'image' dari tabel 'blogs'
});
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTanggalToCobaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('coba', function (Blueprint $table) {
$table->timestamp('tanggal')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('coba', function (Blueprint $table) {
$table->dropColumn('tanggal');
});
}
}

View File

@ -0,0 +1,27 @@
<?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('waterflow', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('waterflow');
}
};

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateWaterflowTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('waterflow', function (Blueprint $table) {
$table->id();
$table->float('waterflow1'); // Kolom waterflow1 dengan tipe float
$table->float('waterflow2'); // Kolom waterflow2 dengan tipe float
$table->timestamp('tanggal')->useCurrent(); // Kolom tanggal dengan tipe timestamp, menggunakan nilai default saat ini
// Tambahkan indeks pada kolom 'tanggal' jika Anda berencana untuk sering melakukan pencarian berdasarkan tanggal
// $table->index('tanggal');
// Jika Anda ingin menggunakan kolom id sebagai primary key
// $table->primary('id');
// Jika Anda ingin menonaktifkan pengaturan timestamps default (created_at dan updated_at)
// $table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('waterflow');
}
}

View File

@ -0,0 +1,27 @@
<?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('waterflow2s', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('waterflow2s');
}
};

View File

@ -0,0 +1,26 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Blog;
class BlogSeeder extends Seeder
{
public function run()
{
Blog::create([
'title' => 'Judul Artikel Pertama',
'content' => 'Ini adalah konten dari artikel pertama.',
'author' => 'Nama Penulis 1',
]);
Blog::create([
'title' => 'Judul Artikel Kedua',
'content' => 'Ini adalah konten dari artikel kedua.',
'author' => 'Nama Penulis 2',
]);
// Tambahkan data dummy lainnya sesuai kebutuhan
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Faker\Factory as Faker;
class CobaSeeder extends Seeder
{
public function run()
{
$faker = Faker::create();
for ($i = 0; $i < 10; $i++) {
DB::table('coba')->insert([
'ultrasonik' => $faker->randomFloat(2, 0, 100), // Data float acak antara 0 dan 100 dengan 2 desimal
'tanggal' => now() // Menyimpan waktu saat ini
]);
echo "Inserted record $i\n";
}
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$this->call([
Waterflow1Seeder::class,
Waterflow2Seeder::class,
]);
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Faker\Factory as Faker;
use Carbon\Carbon;
class TdsSeeder extends Seeder
{
public function run()
{
$faker = Faker::create();
$startDate = Carbon::create(2024, 7, 24, 6, 0, 0); // Mulai dari 24-07-2024 jam 06:00
$endDate = Carbon::create(2024, 7, 28, 16, 0, 0); // Berakhir pada 28-07-2024 jam 16:00
// Loop untuk menghasilkan data dari startDate hingga endDate dengan interval 3 jam
while ($startDate <= $endDate) {
DB::table('tds')->insert([
'tds' => $faker->numberBetween(1160, 1190), // Data tds acak antara 1160 dan 1190
'tanggal' => $startDate->copy() // Salin waktu saat ini
]);
echo "Inserted record for " . $startDate->toDateTimeString() . "\n";
$startDate->addHours(3); // Interval 3 jam
}
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Waterflow1;
use Faker\Factory as Faker;
class Waterflow1Seeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
foreach(range(1, 50) as $index) {
Waterflow1::create([
'arus' => $faker->randomFloat(2, 0.0, 10.0), // Arus dalam rentang 0.0 hingga 10.0 Ampere
'total' => $faker->randomFloat(2, 0.0, 1000.0), // Total arus dalam rentang 0.0 hingga 1000.0
'tanggal' => $faker->dateTimeThisYear() // Tanggal acak dalam tahun ini
]);
}
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Waterflow2;
use Faker\Factory as Faker;
class Waterflow2Seeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
foreach(range(1, 50) as $index) {
Waterflow2::create([
'arus' => $faker->randomFloat(2, 0.0, 10.0), // Arus dalam rentang 0.0 hingga 10.0 Ampere
'total' => $faker->randomFloat(2, 0.0, 1000.0), // Total arus dalam rentang 0.0 hingga 1000.0
'tanggal' => $faker->dateTimeThisYear() // Tanggal acak dalam tahun ini
]);
}
}
}

104
ds/.gitignore vendored Normal file
View File

@ -0,0 +1,104 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port

201
ds/LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

28
ds/README.md Normal file
View File

@ -0,0 +1,28 @@
# mqtt-custom-dashboard-node-js
A custom MQTT dashboard built using Node.js that can be used to display sensor readings from a BME280 sensor
![Featured Image - Custom MQTT Dashboard](https://user-images.githubusercontent.com/69466026/213635253-3e988d9e-bc5b-49fe-9ef5-d1bfcd38075b.jpg)
## Write up
[How to build your own custom MQTT dashboard?](https://www.donskytech.com/how-to-build-your-own-custom-mqtt-dashboard/)
## How to run
You should have Node.js installed in your workstation
Clone the repository
``` git clone https://github.com/donskytech/mqtt-custom-dashboard-node-js.git ```
``` cd mqtt-custom-dashboard-node-js ```
Rename the .env.local to .env
``` mv .env.local .env ```
Edit the .env and set the MQTT broker URL that you are using
```
NAME=DONSKYTECH
DASHBOARD_TITLE=MQTT DASHBOARD
MQTT_BROKER=ws://127.0.01:9001/mqtt
MQTT_TOPIC=sensorReadings
```
Install the dependencies and run the project
``` npm install && npm run dev ```

30
ds/app.js Normal file
View File

@ -0,0 +1,30 @@
const express = require("express");
const app = express();
const port = 3000;
// load dotenv to read environment variables
require("dotenv").config();
// template view engine
app.set("view engine", "ejs");
// Serve Static Files
app.use(express.static("public"));
//routes
const dashboardRouter = require("./routes/dashboard");
app.get("/mqttConnDetails", (req, res) => {
res.send(
JSON.stringify({
mqttServer: process.env.MQTT_BROKER,
mqttTopic: process.env.MQTT_TOPIC,
})
);
});
app.get("/", dashboardRouter);
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});

2046
ds/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

29
ds/package.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "mqtt-custom-dashboard-node",
"version": "1.0.0",
"description": "A custom MQTT dashboard built using Node.js that can be used to display sensor readings from a BME280 sensor",
"main": "index.js",
"scripts": {
"prod": "node app.js",
"dev": "nodemon app.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/donskytech/mqtt-custom-dashboard-node-js.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/donskytech/mqtt-custom-dashboard-node-js/issues"
},
"homepage": "https://github.com/donskytech/mqtt-custom-dashboard-node-js#readme",
"dependencies": {
"dotenv": "^16.0.3",
"ejs": "^3.1.8",
"express": "^4.18.2"
},
"devDependencies": {
"nodemon": "^3.1.0"
}
}

BIN
ds/public/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

554
ds/public/index.js Normal file
View File

@ -0,0 +1,554 @@
// Import MQTT service
import { MQTTService } from "./mqttService.js";
// Target specific HTML items
const sideMenu = document.querySelector("aside");
const menuBtn = document.querySelector("#menu-btn");
const closeBtn = document.querySelector("#close-btn");
const themeToggler = document.querySelector(".theme-toggler");
// Holds the background color of all chart
var chartBGColor = getComputedStyle(document.body).getPropertyValue(
"--chart-background"
);
var chartFontColor = getComputedStyle(document.body).getPropertyValue(
"--chart-font-color"
);
var chartAxisColor = getComputedStyle(document.body).getPropertyValue(
"--chart-axis-color"
);
/*
Event listeners for any HTML click
*/
menuBtn.addEventListener("click", () => {
sideMenu.style.display = "block";
});
closeBtn.addEventListener("click", () => {
sideMenu.style.display = "none";
});
themeToggler.addEventListener("click", () => {
document.body.classList.toggle("dark-theme-variables");
themeToggler.querySelector("span:nth-child(1)").classList.toggle("active");
themeToggler.querySelector("span:nth-child(2)").classList.toggle("active");
// Update Chart background
chartBGColor = getComputedStyle(document.body).getPropertyValue(
"--chart-background"
);
chartFontColor = getComputedStyle(document.body).getPropertyValue(
"--chart-font-color"
);
chartAxisColor = getComputedStyle(document.body).getPropertyValue(
"--chart-axis-color"
);
updateChartsBackground();
});
/*
Plotly.js graph and chart setup code
*/
var temperatureHistoryDiv = document.getElementById("temperature-history");
var humidityHistoryDiv = document.getElementById("humidity-history");
var pressureHistoryDiv = document.getElementById("pressure-history");
var altitudeHistoryDiv = document.getElementById("altitude-history");
var temperatureGaugeDiv = document.getElementById("temperature-gauge");
var humidityGaugeDiv = document.getElementById("humidity-gauge");
var pressureGaugeDiv = document.getElementById("pressure-gauge");
var altitudeGaugeDiv = document.getElementById("altitude-gauge");
const historyCharts = [
temperatureHistoryDiv,
humidityHistoryDiv,
pressureHistoryDiv,
altitudeHistoryDiv,
];
const gaugeCharts = [
temperatureGaugeDiv,
humidityGaugeDiv,
pressureGaugeDiv,
altitudeGaugeDiv,
];
// History Data
var temperatureTrace = {
x: [],
y: [],
name: "Temperature",
mode: "lines+markers",
type: "line",
};
var humidityTrace = {
x: [],
y: [],
name: "Humidity",
mode: "lines+markers",
type: "line",
};
var pressureTrace = {
x: [],
y: [],
name: "Pressure",
mode: "lines+markers",
type: "line",
};
var altitudeTrace = {
x: [],
y: [],
name: "Altitude",
mode: "lines+markers",
type: "line",
};
var temperatureLayout = {
autosize: true,
title: {
text: "Temperature",
},
font: {
size: 12,
color: chartFontColor,
family: "poppins, san-serif",
},
colorway: ["#05AD86"],
margin: { t: 40, b: 40, l: 30, r: 30, pad: 10 },
plot_bgcolor: chartBGColor,
paper_bgcolor: chartBGColor,
xaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
gridwidth: "2",
autorange: true,
},
yaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
gridwidth: "2",
autorange: true,
},
};
var humidityLayout = {
autosize: true,
title: {
text: "Humidity",
},
font: {
size: 12,
color: chartFontColor,
family: "poppins, san-serif",
},
colorway: ["#05AD86"],
margin: { t: 40, b: 40, l: 30, r: 30, pad: 0 },
plot_bgcolor: chartBGColor,
paper_bgcolor: chartBGColor,
xaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
gridwidth: "2",
},
yaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
},
};
var pressureLayout = {
autosize: true,
title: {
text: "Pressure",
},
font: {
size: 12,
color: chartFontColor,
family: "poppins, san-serif",
},
colorway: ["#05AD86"],
margin: { t: 40, b: 40, l: 30, r: 30, pad: 0 },
plot_bgcolor: chartBGColor,
paper_bgcolor: chartBGColor,
xaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
gridwidth: "2",
},
yaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
},
};
var altitudeLayout = {
autosize: true,
title: {
text: "Altitude",
},
font: {
size: 12,
color: chartFontColor,
family: "poppins, san-serif",
},
colorway: ["#05AD86"],
margin: { t: 40, b: 40, l: 30, r: 30, pad: 0 },
plot_bgcolor: chartBGColor,
paper_bgcolor: chartBGColor,
xaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
gridwidth: "2",
},
yaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
},
};
var config = { responsive: true, displayModeBar: false };
// Event listener when page is loaded
window.addEventListener("load", (event) => {
Plotly.newPlot(
temperatureHistoryDiv,
[temperatureTrace],
temperatureLayout,
config
);
Plotly.newPlot(humidityHistoryDiv, [humidityTrace], humidityLayout, config);
Plotly.newPlot(pressureHistoryDiv, [pressureTrace], pressureLayout, config);
Plotly.newPlot(altitudeHistoryDiv, [altitudeTrace], altitudeLayout, config);
// Get MQTT Connection
fetchMQTTConnection();
// Run it initially
handleDeviceChange(mediaQuery);
});
// Gauge Data
var temperatureData = [
{
domain: { x: [0, 1], y: [0, 1] },
value: 0,
title: { text: "Temperature" },
type: "indicator",
mode: "gauge+number+delta",
delta: { reference: 30 },
gauge: {
axis: { range: [null, 50] },
steps: [
{ range: [0, 20], color: "lightgray" },
{ range: [20, 30], color: "gray" },
],
threshold: {
line: { color: "red", width: 4 },
thickness: 0.75,
value: 30,
},
},
},
];
var humidityData = [
{
domain: { x: [0, 1], y: [0, 1] },
value: 0,
title: { text: "Humidity" },
type: "indicator",
mode: "gauge+number+delta",
delta: { reference: 50 },
gauge: {
axis: { range: [null, 100] },
steps: [
{ range: [0, 20], color: "lightgray" },
{ range: [20, 30], color: "gray" },
],
threshold: {
line: { color: "red", width: 4 },
thickness: 0.75,
value: 30,
},
},
},
];
var pressureData = [
{
domain: { x: [0, 1], y: [0, 1] },
value: 0,
title: { text: "Pressure" },
type: "indicator",
mode: "gauge+number+delta",
delta: { reference: 750 },
gauge: {
axis: { range: [null, 1100] },
steps: [
{ range: [0, 300], color: "lightgray" },
{ range: [300, 700], color: "gray" },
],
threshold: {
line: { color: "red", width: 4 },
thickness: 0.75,
value: 30,
},
},
},
];
var altitudeData = [
{
domain: { x: [0, 1], y: [0, 1] },
value: 0,
title: { text: "Altitude" },
type: "indicator",
mode: "gauge+number+delta",
delta: { reference: 60 },
gauge: {
axis: { range: [null, 150] },
steps: [
{ range: [0, 50], color: "lightgray" },
{ range: [50, 100], color: "gray" },
],
threshold: {
line: { color: "red", width: 4 },
thickness: 0.75,
value: 30,
},
},
},
];
var layout = { width: 300, height: 250, margin: { t: 0, b: 0, l: 0, r: 0 } };
Plotly.newPlot(temperatureGaugeDiv, temperatureData, layout);
Plotly.newPlot(humidityGaugeDiv, humidityData, layout);
Plotly.newPlot(pressureGaugeDiv, pressureData, layout);
Plotly.newPlot(altitudeGaugeDiv, altitudeData, layout);
// Will hold the arrays we receive from our BME280 sensor
// Temperature
let newTempXArray = [];
let newTempYArray = [];
// Humidity
let newHumidityXArray = [];
let newHumidityYArray = [];
// Pressure
let newPressureXArray = [];
let newPressureYArray = [];
// Altitude
let newAltitudeXArray = [];
let newAltitudeYArray = [];
// The maximum number of data points displayed on our scatter/line graph
let MAX_GRAPH_POINTS = 12;
let ctr = 0;
// Callback function that will retrieve our latest sensor readings and redraw our Gauge with the latest readings
function updateSensorReadings(jsonResponse) {
console.log(typeof jsonResponse);
console.log(jsonResponse);
let temperature = Number(jsonResponse.temperature).toFixed(2);
let humidity = Number(jsonResponse.humidity).toFixed(2);
let pressure = Number(jsonResponse.pressure).toFixed(2);
let altitude = Number(jsonResponse.altitude).toFixed(2);
updateBoxes(temperature, humidity, pressure, altitude);
updateGauge(temperature, humidity, pressure, altitude);
// Update Temperature Line Chart
updateCharts(
temperatureHistoryDiv,
newTempXArray,
newTempYArray,
temperature
);
// Update Humidity Line Chart
updateCharts(
humidityHistoryDiv,
newHumidityXArray,
newHumidityYArray,
humidity
);
// Update Pressure Line Chart
updateCharts(
pressureHistoryDiv,
newPressureXArray,
newPressureYArray,
pressure
);
// Update Altitude Line Chart
updateCharts(
altitudeHistoryDiv,
newAltitudeXArray,
newAltitudeYArray,
altitude
);
}
function updateBoxes(temperature, humidity, pressure, altitude) {
let temperatureDiv = document.getElementById("temperature");
let humidityDiv = document.getElementById("humidity");
let pressureDiv = document.getElementById("pressure");
let altitudeDiv = document.getElementById("altitude");
temperatureDiv.innerHTML = temperature + " C";
humidityDiv.innerHTML = humidity + " %";
pressureDiv.innerHTML = pressure + " hPa";
altitudeDiv.innerHTML = altitude + " m";
}
function updateGauge(temperature, humidity, pressure, altitude) {
var temperature_update = {
value: temperature,
};
var humidity_update = {
value: humidity,
};
var pressure_update = {
value: pressure,
};
var altitude_update = {
value: altitude,
};
Plotly.update(temperatureGaugeDiv, temperature_update);
Plotly.update(humidityGaugeDiv, humidity_update);
Plotly.update(pressureGaugeDiv, pressure_update);
Plotly.update(altitudeGaugeDiv, altitude_update);
}
function updateCharts(lineChartDiv, xArray, yArray, sensorRead) {
if (xArray.length >= MAX_GRAPH_POINTS) {
xArray.shift();
}
if (yArray.length >= MAX_GRAPH_POINTS) {
yArray.shift();
}
xArray.push(ctr++);
yArray.push(sensorRead);
var data_update = {
x: [xArray],
y: [yArray],
};
Plotly.update(lineChartDiv, data_update);
}
function updateChartsBackground() {
// updates the background color of historical charts
var updateHistory = {
plot_bgcolor: chartBGColor,
paper_bgcolor: chartBGColor,
font: {
color: chartFontColor,
},
xaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
},
yaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
},
};
historyCharts.forEach((chart) => Plotly.relayout(chart, updateHistory));
// updates the background color of gauge charts
var gaugeHistory = {
plot_bgcolor: chartBGColor,
paper_bgcolor: chartBGColor,
font: {
color: chartFontColor,
},
xaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
},
yaxis: {
color: chartAxisColor,
linecolor: chartAxisColor,
},
};
gaugeCharts.forEach((chart) => Plotly.relayout(chart, gaugeHistory));
}
const mediaQuery = window.matchMedia("(max-width: 600px)");
mediaQuery.addEventListener("change", function (e) {
handleDeviceChange(e);
});
function handleDeviceChange(e) {
if (e.matches) {
console.log("Inside Mobile");
var updateHistory = {
width: 323,
height: 250,
"xaxis.autorange": true,
"yaxis.autorange": true,
};
historyCharts.forEach((chart) => Plotly.relayout(chart, updateHistory));
} else {
var updateHistory = {
width: 550,
height: 260,
"xaxis.autorange": true,
"yaxis.autorange": true,
};
historyCharts.forEach((chart) => Plotly.relayout(chart, updateHistory));
}
}
/*
MQTT Message Handling Code
*/
const mqttStatus = document.querySelector(".status");
function onConnect(message) {
mqttStatus.textContent = "Connected";
}
function onMessage(topic, message) {
var stringResponse = message.toString();
var messageResponse = JSON.parse(stringResponse);
updateSensorReadings(messageResponse);
}
function onError(error) {
console.log(`Error encountered :: ${error}`);
mqttStatus.textContent = "Error";
}
function onClose() {
console.log(`MQTT connection closed!`);
mqttStatus.textContent = "Closed";
}
function fetchMQTTConnection() {
fetch("/mqttConnDetails", {
method: "GET",
headers: {
"Content-type": "application/json; charset=UTF-8",
},
})
.then(function (response) {
return response.json();
})
.then(function (data) {
initializeMQTTConnection(data.mqttServer, data.mqttTopic);
})
.catch((error) => console.error("Error getting MQTT Connection :", error));
}
function initializeMQTTConnection(mqttServer, mqttTopic) {
console.log(
`Initializing connection to :: ${mqttServer}, topic :: ${mqttTopic}`
);
var fnCallbacks = { onConnect, onMessage, onError, onClose };
var mqttService = new MQTTService(mqttServer, fnCallbacks);
mqttService.connect();
mqttService.subscribe(mqttTopic);
}

50
ds/public/mqttService.js Normal file
View File

@ -0,0 +1,50 @@
export class MQTTService {
constructor(host, messageCallbacks) {
this.mqttClient = null;
this.host = host;
this.messageCallbacks = messageCallbacks;
}
connect() {
this.mqttClient = mqtt.connect(this.host);
// MQTT Callback for 'error' event
this.mqttClient.on("error", (err) => {
console.log(err);
this.mqttClient.end();
if (this.messageCallbacks && this.messageCallbacks.onError)
this.messageCallbacks.onError(err);
});
// MQTT Callback for 'connect' event
this.mqttClient.on("connect", () => {
console.log(`MQTT client connected`);
if (this.messageCallbacks && this.messageCallbacks.onConnect) {
this.messageCallbacks.onConnect("Connected");
}
});
// Call the message callback function when message arrived
this.mqttClient.on("message", (topic, message) => {
if (this.messageCallbacks && this.messageCallbacks.onMessage) {
this.messageCallbacks.onMessage(topic, message);
}
});
this.mqttClient.on("close", () => {
console.log(`MQTT client disconnected`);
if (this.messageCallbacks && this.messageCallbacks.onClose)
this.messageCallbacks.onClose();
});
}
// Publish MQTT Message
publish(topic, message, options) {
this.mqttClient.publish(topic, message);
}
// Subscribe to MQTT Message
subscribe(topic, options) {
this.mqttClient.subscribe(topic, options);
}
}

553
ds/public/style.css Normal file
View File

@ -0,0 +1,553 @@
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap");
:root {
--color-primary: #7380ec;
--color-danger: #ff7782;
--color-success: #41f1b6;
--color-warning: #ffbb55;
--color-white: #fff;
--color-info-dark: #7d8da1;
--color-info-light: #dce1eb;
--color-dark: #363949;
--color-light: rgba(132, 139, 200, 0.18);
--color-primary-variant: #111e88;
--color-dark-variant: #677483;
--color-background: #f6f6f9;
--color-insight-1: rgb(99, 209, 35);
--color-insight-2: rgb(233, 245, 59);
--color-insight-3: rgb(204, 52, 67);
--color-insight-4: rgb(56, 183, 238);
--card-border-radius: 2rem;
--border-radius-1: 0.4rem;
--border-radius-2: 0.8rem;
--border-radius-3: 1.2rem;
--card-padding: 1.8rem;
--padding-1: 1.2rem;
--box-shadow: 0 2rem 3rem var(--color-light);
/* Plotly Chart Color */
--chart-background: #fff;
--chart-font-color: #444;
--chart-axis-color: #444;
}
/* Dark Theme Variables */
.dark-theme-variables {
--color-background: #090d3e;
--color-white: #0b0f4a;
--color-primary: #fff;
--color-dark: #edeffd;
--color-dark-variant: #fff;
--color-light: rgba(0, 0, 0, 0.4);
--box-shadow: 0 2rem 3rem var(--color-light);
--chart-background: #0d1256;
--chart-font-color: #fff;
--chart-axis-color: #fff;
}
* {
margin: 0;
padding: 0;
outline: 0;
appearance: none;
text-decoration: none;
list-style: none;
box-sizing: border-box;
}
html {
font-size: 14px;
}
body {
width: 100vw;
height: 100vh;
font-family: poppins, san-serif;
font-size: 0.88rem;
background: var(--color-background);
user-select: none;
overflow-x: hidden;
color: var(--color-dark-variant);
}
.container {
display: grid;
width: 96%;
margin: 0 auto;
gap: 1.8rem;
grid-template-columns: 14rem auto 30rem;
}
a {
color: var(--color-dark);
}
img {
display: block;
width: 100%;
}
h1 {
font-weight: 800;
font-size: 1.8rem;
}
h2 {
font-size: 1.4rem;
}
h3 {
font-size: 0.87rem;
}
h4 {
font-size: 0.8rem;
}
h5 {
font-size: 0.77rem;
}
small {
font-size: 0.75rem;
}
.profile-photo {
width: 2.8rem;
height: 2.8rem;
border-radius: 50%;
overflow: hidden;
}
.text-muted {
color: var(--color-info-light);
}
p {
color: var(--color-dark-variant);
}
b {
color: var(--color-dark-variant);
}
.primary {
color: var(--color-primary);
}
.danger {
color: var(--color-danger);
}
.success {
color: var(--color-success);
}
.warning {
color: var(--color-warning);
}
/***** Sidebar Image*****/
aside {
height: 100vh;
}
aside .top {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 1.4rem;
}
aside .logo {
display: flex;
gap: 0.8rem;
}
aside .logo img {
width: 2rem;
height: 2re;
}
aside .close {
display: none;
}
/***** Sidebar Links*****/
aside .sidebar {
display: flex;
flex-direction: column;
height: 86vh;
position: relative;
top: 3rem;
}
aside h3 {
font-weight: 500;
}
aside .sidebar a {
display: flex;
color: var(--color-info-dark);
margin-left: 2rem;
gap: 1rem;
align-items: center;
position: relative;
height: 3.7rem;
transition: all 300ms ease;
}
aside .sidebar a span {
font-size: 1.6rem;
transition: all 300ms ease;
}
/* aside .sidebar a:last-child {
position: absolute;
bottom: 2rem;
width: 100%;
} */
aside .sidebar a.active {
background: var(--color-light);
color: var(--color-primary);
margin-left: 0;
}
aside .sidebar a.active:before {
content: "";
width: 6px;
height: 100%;
background: var(--color-primary);
}
aside .sidebar a.active span {
color: var(--color-primary);
margin-left: calc(1rem - 6px);
}
aside .sidebar a:hover {
color: var(--color-primary);
}
aside .sidebar a:hover span {
margin-left: 1rem;
}
/************* main ******************/
main {
margin-top: 1.4rem;
}
main .insights {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 1.6rem;
}
main .insights > div {
background: var(--color-white);
padding: var(--card-padding);
border-radius: var(--card-border-radius);
margin-top: 1rem;
box-shadow: var(--box-shadow);
transition: all 300ms ease;
}
main .insights > div:hover {
box-shadow: none;
}
main .insights > div span {
background: var(--color-primary);
padding: 0.5rem;
border-radius: 50%;
color: var(--color-white);
font-size: 2rem;
}
main .insights > div.temperature span {
background: var(--color-insight-1);
}
main .insights > div.humidity span {
background: var(--color-insight-2);
}
main .insights > div.pressure span {
background: var(--color-insight-3);
}
main .insights > div.altitude span {
background: var(--color-insight-4);
}
main .insights > div .middle {
display: flex;
align-items: center;
justify-content: space-between;
}
main .insights h3 {
margin: 1rem 0 0.6rem;
font-size: 1rem;
}
/************* End of Insights ******************/
main .histories {
margin-top: 2rem;
}
main .history-charts {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 2.5rem;
background: var(--color-white);
border-radius: var(--border-radius-1);
padding: var(--card-padding);
text-align: center;
box-shadow: var(--box-shadow);
}
main .history-charts:hover {
box-shadow: none;
}
main .history-charts .history-divs {
text-align: center;
}
main .histories h2 {
margin-bottom: 0.8rem;
}
/* ********RIGHT ********** */
.right {
margin-top: 1.4rem;
}
.right .top {
display: flex;
justify-content: end;
gap: 2rem;
}
.right .top button {
display: none;
}
.right .theme-toggler {
background: var(--color-light);
display: flex;
justify-content: space-between;
align-items: center;
height: 1.6rem;
width: 4.2rem;
cursor: pointer;
border-radius: var(--border-radius-1);
}
.right .theme-toggler span {
font-size: 1.2rem;
width: 50%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.right .theme-toggler span.active {
background: var(--color-primary);
color: white;
border-radius: var(--border-radius-1);
}
/* GAUGE CHARTS */
.right .gauge-charts {
margin-top: 2rem;
}
.right .gauge-charts .item {
background: var(--color-white);
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
margin-bottom: 0.7rem;
padding: 1.4rem var(--card-padding);
border-radius: var(--border-radius-3);
box-shadow: var(--box-shadow);
transition: all 300ms ease;
}
.right .gauge-charts .item:hover {
box-shadow: none;
}
.right .gauge-charts .item .right {
display: flex;
justify-content: space-between;
align-items: start;
margin: 0;
width: 100%;
}
.right .gauge-charts .item .icon {
padding: 0.6rem;
color: var(--color-white);
border-radius: 50%;
background: var(--color-primary);
display: flex;
}
.right .gauge-charts .item.offline .icon {
background: var(--color-danger);
}
/* MEDIA QUERIES */
@media screen and (max-width: 1200px) {
.container {
width: 94%;
grid-template-columns: 7rem auto 23rem;
}
aside .logo h2 {
display: none;
}
aside .sidebar h3 {
display: none;
}
aside .sidebar a {
width: 5.6rem;
}
aside .sidebar a:last-child {
position: relative;
margin-top: 1.8rem;
}
main .insights {
grid-template-columns: 1fr;
}
main .histories {
width: 94%;
position: absolute;
left: 50%;
transform: translateX(-50%);
margin: 2rem 0 0 8.8rem;
}
main .histories .history-charts {
grid-template-columns: 1fr;
width: 54vw;
}
}
@media only screen and (max-width: 992px) {
.container {
width: 94%;
grid-template-columns: 12rem auto 23rem;
}
main .insights {
grid-template-columns: repeat(2, 1fr);
gap: 1.6rem;
}
main .histories .history-charts {
grid-template-columns: 1fr;
align-items: center;
justify-content: center;
}
}
@media screen and (max-width: 768px) {
.container {
width: 100%;
grid-template-columns: 1fr;
/* height: 100vh; */
}
aside {
position: fixed;
left: -100%;
background: var(--color-white);
width: 18rem;
z-index: 3;
box-shadow: 1rem 3rem 4rem var(--color-light);
height: 100vh;
padding-right: var(--card-padding);
display: none;
animation: showMenu 400ms ease forwards;
}
@keyframes showMenu {
to {
left: 0;
}
}
aside .logo {
margin-left: 1rem;
}
aside .logo h2 {
display: inline;
}
aside .sidebar h3 {
display: inline;
}
aside .sidebar a {
width: 100%;
height: 3.4rem;
}
/* aside .sidebar a:last-child {
position: absolute;
bottom: 5rem;
} */
aside .close {
display: inline-block;
cursor: pointer;
}
main {
margin: 8rem 2rem 2rem 2rem;
padding: 0 1rem;
}
main .histories {
position: relative;
margin: 3rem 0 0 0;
width: 100%;
}
main .histories .history-charts {
width: 100%;
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.right {
width: 90%;
margin: 0 auto 0rem auto;
}
.right .top {
position: fixed;
top: 0;
left: 0;
align-items: center;
padding: 0 0.8rem;
height: 4.6rem;
background: var(--color-white);
width: 100%;
margin: 0;
z-index: 2;
box-shadow: 0 1rem 1 rem var(--color-light);
}
.right .top .theme-toggler {
width: 4.4rem;
position: absolute;
right: 2rem;
}
.right .profile .info {
display: none;
}
.right .top button {
display: inline-block;
background: transparent;
cursor: pointer;
color: var(--color-dark);
position: absolute;
left: 1rem;
}
.right .top button span {
font-size: 2rem;
}
}
@media screen and (max-width: 600px) {
.container {
width: 100%;
grid-template-columns: 1fr;
margin: 1rem 0 1rem 0;
}
main {
margin: 5rem 1rem 1rem 1rem;
padding: 0 1rem;
width: 90vw;
}
main .insights {
gap: 0.4rem;
}
main .insights > div {
padding: 0.4rem;
}
main .history-charts {
display: grid;
grid-template-columns: 1fr;
}
}

12
ds/routes/dashboard.js Normal file
View File

@ -0,0 +1,12 @@
const express = require("express");
const router = express.Router();
// Home page - Dashboard.
router.get("/", function (req, res) {
res.render("pages/dashboard", {
name: process.env.NAME,
dashboardTitle: process.env.DASHBOARD_TITLE,
});
});
module.exports = router;

View File

@ -0,0 +1,134 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%=dashboardTitle%></title>
<link
href="https://fonts.googleapis.com/icon?family=Material+Symbols+Sharp"
rel="stylesheet"
/>
<script src="https://cdn.plot.ly/plotly-2.16.1.min.js"></script>
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div class="container">
<aside>
<div class="top">
<div class="logo">
<img src="images/logo.png" alt="" />
<h2><%=name%></h2>
</div>
<div class="close" id="close-btn">
<span class="material-symbols-sharp"> close </span>
</div>
</div>
<div class="sidebar">
<a href="#" class="active">
<span class="material-symbols-sharp"> dashboard </span>
<h3>Dashboard</h3>
</a>
</div>
</aside>
<main>
<h1><%=dashboardTitle%></h1>
<div class="connection-status">
<h3>Connection Status: <span class="status">Disconnected</span></h3>
</div>
<div class="insights">
<div class="temperature">
<div class="middle">
<div class="left">
<h3>Temperature</h3>
<h1 id="temperature"></h1>
</div>
<div class="icon">
<span class="material-symbols-sharp"> device_thermostat </span>
</div>
</div>
</div>
<!-- End of temperature -->
<div class="humidity">
<div class="middle">
<div class="left">
<h3>Humidity</h3>
<h1 id="humidity"></h1>
</div>
<div class="icon">
<span class="material-symbols-sharp">
humidity_percentage
</span>
</div>
</div>
</div>
<!-- End of humidity -->
<div class="pressure">
<div class="middle">
<div class="left">
<h3>Pressure</h3>
<h1 id="pressure"></h1>
</div>
<div class="icon">
<span class="material-symbols-sharp"> speed </span>
</div>
</div>
</div>
<!-- End of pressure -->
<div class="altitude">
<div class="middle">
<div class="left">
<h3>Approx Altitude</h3>
<h1 id="altitude"></h1>
</div>
<div class="icon">
<span class="material-symbols-sharp"> altitude </span>
</div>
</div>
</div>
<!-- End of altitude -->
</div>
<!-- End of Insights -->
<div class="histories">
<h2>Historical Charts</h2>
<div class="history-charts">
<div id="temperature-history" class="history-divs"></div>
<div id="humidity-history" class="history-divs"></div>
<div id="pressure-history" class="history-divs"></div>
<div id="altitude-history" class="history-divs"></div>
</div>
</div>
</main>
<div class="right">
<div class="top">
<button id="menu-btn">
<span class="material-symbols-sharp"> menu </span>
</button>
<div class="theme-toggler">
<span class="material-symbols-sharp active"> light_mode </span>
<span class="material-symbols-sharp"> dark_mode </span>
</div>
</div>
<!-- End of top -->
<div class="gauge-charts">
<h2>Gauge Charts</h2>
<div class="item">
<div id="temperature-gauge"></div>
</div>
<div class="item">
<div id="humidity-gauge"></div>
</div>
<div class="item">
<div id="pressure-gauge"></div>
</div>
<div class="item">
<div id="altitude-gauge"></div>
</div>
</div>
</div>
</div>
<script type="module" src="./index.js"></script>
<script type="module" src="./mqttService.js"></script>
</body>
</html>

1312
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

20
package.json Normal file
View File

@ -0,0 +1,20 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"@popperjs/core": "^2.11.6",
"axios": "^1.6.4",
"bootstrap": "^5.2.3",
"laravel-vite-plugin": "^1.0.2",
"sass": "^1.56.1",
"vite": "^5.0"
},
"dependencies": {
"chart.js": "^4.4.3",
"vue": "^3.4.31"
}
}

33
phpunit.xml Normal file
View File

@ -0,0 +1,33 @@
<?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>tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>app</directory>
</include>
</source>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_STORE" value="array"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
</phpunit>

21
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>

0
public/favicon.ico Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

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