Commit 9b8b481e authored by Ashan Tharuka's avatar Ashan Tharuka

Merge branch 'main' into 'it19202464'

Main

See merge request !7
parents 2e904b49 8dfa5ab4
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
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
* text=auto
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
/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
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
### Premium Partners
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Audit;
use App\Models\Queue;
use App\Models\Fueltype;
use App\Models\Station;
use App\Models\User;
use App\Models\Fuelcapacity;
class AuditController extends Controller
{
// This function for get Audit
public function get_audit(Request $req){
$response = [
"amount" => '',
"filled" => '',
];
if($req->role == "station"){
$station = Station::where('user_id',$req->id)->first();
$response = [
"amount" => Audit::where('station_id',$station->id)->sum('amount'),
"filled" => Audit::where('station_id',$station->id)->count()
];
}else if($req->role == "user"){
$response = [
"amount" => Audit::where('user_id',$req->id)->sum('amount'),
"filled" => Audit::where('user_id',$req->id)->count(),
"list" => Audit::join('stations','stations.id','=','audits.station_id')
->join('fueltypes','fueltypes.id','=','audits.fueltype_id')->join('vehicles','vehicles.id','=','audits.vehicle_id')
->join('users','users.id','=','audits.user_id')->where('audits.user_id',$req->id)
->get(['audits.id as aid','users.name as uname','stations.name as sname', 'vehicles.type as vtype','vehicles.vehicle_no as vno','fueltypes.name as ftyoe','audits.amount','audits.qty','audits.created_at'])
];
}
return response()->json(['response'=>$response]);
}
// This function for create a new Audit
public function create_audit(Request $req){
$fueltype = Fueltype::find($req->fueltype_id);
$audit = new Audit;
$audit->qty = $req->qty;
$audit->amount = $fueltype->price * $req->qty;
$audit->user_id = $req->user_id;
$audit->vehicle_id = $req->vehicle_id;
$audit->station_id = $req->station_id;
$audit->fueltype_id = $req->fueltype_id;
$audit->save();
$fuelcapacity = Fuelcapacity::where('fueltype_id',$req->fueltype_id)->where('station_id',$req->station_id)->first();
$fuelcapacity->update([
'current_qty' => $fuelcapacity->current_qty - $req->qty,
]);
$queue = Queue::find($req->qid);
$queue->update([
'status' => 1,
]);
$message = 'success';
return response()->json(['message'=>$message]);
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use App\Models\Bowser;
use App\Models\User;
use App\Models\Station;
use Auth;
class BowserController extends Controller
{
// This function for get Bowsers
public function get_bowser(Request $req){
$respond = "";
if($req->id>0){
$station = Station::where('user_id',$req->id)->first();
$respond = Bowser::join('users','users.id','=','bowsers.user_id')
->where('bowsers.station_id',$station->id)
->get(['bowsers.id','bowsers.name','bowsers.vehicle_no','bowsers.curent_location','bowsers.capacity','users.name as uname','users.email','users.phone']);
}else{
$respond = Bowser::join('users','users.id','=','bowsers.user_id')->get(['bowsers.id','bowsers.name','bowsers.vehicle_no','bowsers.curent_location','bowsers.capacity','users.name as uname','users.email','users.phone']);
}
return response()->json(['respond'=>$respond]);
}
// This function for get Bowsers
public function get_bowser_home(Request $req){
$respond = "";
$respond = Bowser::join('users','users.id','=','bowsers.user_id')
->where('bowsers.user_id',$req->id)
->first(['bowsers.id','bowsers.name','bowsers.vehicle_no','bowsers.curent_location','bowsers.capacity','users.name as uname','users.email','users.phone']);
return response()->json(['respond'=>$respond]);
}
// This function for get Bowsers
public function get_bowser_specific(Request $req){
$respond = "";
$respond = Bowser::join('users','users.id','=','bowsers.user_id')
->where('bowsers.id',$req->id)->first(['bowsers.id','bowsers.name','bowsers.vehicle_no','bowsers.curent_location','bowsers.capacity','users.name as uname','users.email','users.phone']);
return response()->json(['respond'=>$respond]);
}
// This function for create a new Bowser with user
public function create_bowser(Request $req){
$message = '';
$phoneLength = Str::length($req->phone);
$station = Station::where('user_id',$req->station_user_id)->first();
if($this->check_empty($req->name,$req->email,$req->phone,$req->pwd)){
if($phoneLength == 10){
//create new User
$user = new User;
$user->name = $req->name;
$user->email = $req->email;
$user->phone = $req->phone;
$user->password = Hash::make($req->pwd);
$user->role = 'station';
$user->save();
//create new Station
$bowser = new Bowser;
$bowser->name = $req->bname;
$bowser->vehicle_no = $req->vehicle_no;
$bowser->capacity = $req->capacity;
$bowser->curent_location = $station->location;
$bowser->user_id = $user->id;
$bowser->station_id = $station->id;
$bowser->save();
$message = 'success';
}else{
$message = 'Phone number must have 10 digits';
}
}else{
$message = 'Name, Email, Phone and Password cannot be empty';
}
return response()->json(['message'=>$message]);
}
// This function for delete a Bowser with User
public function delete_bowser(Request $req){
$bowser = Bowser::find($req->id);
$user = User::find($bowser->user_id);
$user->delete();
$bowser->delete();
return response()->json(['message'=>"success"]);
}
// This function for update a Bowser with user
public function update_bowser(Request $req){
$bowser = Bowser::find($req->id);
$user = User::find($bowser->user_id);
$bowser->update([
'name' => $req->bname,
'vehicle_no' => $req->vehicle_no,
'capacity' => $req->capacity,
'curent_location' => $req->location,
]);
$user->update([
'name' => $req->name,
'phone' => $req->phone,
]);
return response()->json(['message'=>'success']);
}
// This function for check given fields are empty or not
public function check_empty($name,$email,$phone,$pwd){
if($name != '' && $name != null && $email != '' && $email != null && $phone != '' && $phone != null && $pwd != '' && $pwd != null){
return true;
}else{
return false;
}
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Fueltype;
use App\Models\Fuelcapacity;
use App\Models\Station;
class FuelController extends Controller
{
// This function for get Fuel Types
public function get_fuel_type(Request $req){
$fueltype = "";
if($req->id){
$fueltype = Fueltype::find($req->id);
}else{
$fueltype = Fueltype::all()->orderby('id','DESC');
}
return response()->json(['respond'=>$fueltype]);
}
// This function for create a new Fuel type
public function create_fuel_type(Request $req){
$message = '';
if($this->check_empty($req->name,$req->price)){
//create new User
$fueltype = new Fueltype;
$fueltype->name = $req->name;
$fueltype->price = $req->price;
$fueltype->save();
$message = 'Fuel Type successfully created';
}else{
$message = 'Type or Price cannot be empty';
}
return response()->json(['message'=>$message]);
}
// This function for delete a Fuel type
public function delete_fuel_type(Request $req){
$fueltype = Fueltype::find($req->id);
$fueltype->delete();
return response()->json(['message'=>'success']);
}
// This function for update a Fuel type
public function update_fuel_type(Request $req){
$fueltype = Fueltype::find($req->id);
$fueltype->update([
'name' => $req->name,
'price' => $req->price,
]);
return response()->json(['message'=>'success']);
}
// This function for check given fields are empty or not
public function check_empty($name,$price){
if($name != '' && $name != null && $price != '' && $price != null){
return true;
}else{
return false;
}
}
// This function for get Fuel Types For Dropdowns
public function get_capacity_fuel_type(Request $req){
$fueltype = Fueltype::get(['name as label','price as value'])->orderby('id','DESC');
return response()->json(['respond'=>$fueltype]);
}
// This function for create a new Fuel type
public function create_fuel_capacity(Request $req){
$station = Station::where('user_id',$req->uid)->first();
$message = '';
if(Fuelcapacity::Where('fueltype_id',$req->fid)->Where('station_id',$station->id)->exists()){
$message = 'Already Created';
}else{
//create new Stock
$fuelcapacity = new Fuelcapacity;
$fuelcapacity->fueltype_id = $req->fid;
$fuelcapacity->ini_qty = $req->qty;
$fuelcapacity->current_qty = $req->qty;
$fuelcapacity->station_id = $station->id;
$fuelcapacity->save();
$message = 'success';
}
return response()->json(['message'=>$message]);
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use App\Models\Station;
use App\Models\User;
use App\Models\Fuelcapacity;
use App\Models\Queue;
use App\Models\Vehicle;
use Auth;
class StationController extends Controller
{
// This function for get Stations
public function get_stations(Request $req){
$respond = "";
$queue = '';
if($req->id){
$respond = Station::join('users','users.id','=','stations.user_id')
->where('queues.status','0')
->first(['stations.id','stations.name','stations.location','stations.availability','users.name as uname','users.email','users.phone']);
$queue = Queue::where('station_id',$req->id)->where('status','0')->count();
}else{
$respond = Station::join('users','users.id','=','stations.user_id')->orderby('id','DESC')
->get(['stations.id','stations.name','stations.location','stations.availability','users.name as uname','users.email','users.phone']);
}
return response()->json(['respond'=>$respond,'count'=>$queue]);
}
// This function for create a new Station with user
public function create_station(Request $req){
$message = '';
$phoneLength = Str::length($req->phone);
if($this->check_empty($req->name,$req->email,$req->phone,$req->pwd)){
if($phoneLength == 10){
//create new User
$user = new User;
$user->name = $req->name;
$user->email = $req->email;
$user->phone = $req->phone;
$user->password = Hash::make($req->pwd);
$user->role = 'station';
$user->save();
//create new Station
$station = new Station;
$station->name = $req->sname;
$station->location = $req->location;
$station->user_id = $user->id;
$station->save();
$message = 'Station successfully created';
}else{
$message = 'Phone number must have 10 digits';
}
}else{
$message = 'Name, Email, Phone and Password cannot be empty';
}
return response()->json(['message'=>$message]);
}
// This function for delete a Station with User
public function delete_station(Request $req){
$station = Station::find($req->id);
$user = User::find($station->user_id);
$user->delete();
$station->delete();