Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
22_23-j 51
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
22_23-j 51
22_23-j 51
Commits
5af6b0d9
Commit
5af6b0d9
authored
Feb 07, 2023
by
Hasith Yoman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change controllers
parent
27062319
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
176 deletions
+0
-176
fuel-sliit-bakend-main/app/Http/Controllers/AuditController.php
...liit-bakend-main/app/Http/Controllers/AuditController.php
+0
-72
fuel-sliit-bakend-main/app/Http/Controllers/FuelController.php
...sliit-bakend-main/app/Http/Controllers/FuelController.php
+0
-104
No files found.
fuel-sliit-bakend-main/app/Http/Controllers/AuditController.php
deleted
100644 → 0
View file @
27062319
<?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
]);
}
}
fuel-sliit-bakend-main/app/Http/Controllers/FuelController.php
deleted
100644 → 0
View file @
27062319
<?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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment