Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Rafael Kurniawan
UTS_V3421076
Commits
fa9634c8
Commit
fa9634c8
authored
2 years ago
by
Rafael Kurniawan
Browse files
Options
Download
Email Patches
Plain Diff
Commit
parent
7eb80bfd
master
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/Http/Controllers/api/ControllerApiAgama.php
+12
-3
app/Http/Controllers/api/ControllerApiAgama.php
app/Http/Resources/FormatApi.php
+1
-1
app/Http/Resources/FormatApi.php
routes/api.php
+3
-0
routes/api.php
with
16 additions
and
4 deletions
+16
-4
app/Http/Controllers/api/ControllerApiAgama.php
View file @
fa9634c8
...
...
@@ -38,7 +38,10 @@ class ControllerApiAgama extends Controller
*/
public
function
store
(
Request
$request
)
{
//
$addAgama
=
Agama
::
create
([
'nama_agama'
=>
$request
->
nama_agama
,
]);
return
new
FormatApi
(
true
,
'Add Data Agama Berhasil'
,
$addAgama
);
}
/**
...
...
@@ -73,7 +76,11 @@ class ControllerApiAgama extends Controller
*/
public
function
update
(
Request
$request
,
$id
)
{
//
$agamas
=
Agama
::
findOrFail
(
$id
);
$agamas
->
update
([
'nama_agama'
=>
$request
->
nama_agama
,
]);
return
new
FormatApi
(
true
,
'Update Data Agama'
,
$agamas
);
}
/**
...
...
@@ -84,6 +91,8 @@ class ControllerApiAgama extends Controller
*/
public
function
destroy
(
$id
)
{
//
$agamas
=
Agama
::
findOrFail
(
$id
);
$agamas
->
delete
();
return
new
FormatApi
(
true
,
'Delete Data Agama'
,
$agamas
);
}
}
This diff is collapsed.
Click to expand it.
app/Http/Resources/FormatApi.php
View file @
fa9634c8
...
...
@@ -25,7 +25,7 @@ class FormatApi extends JsonResource
*/
public
function
toArray
(
$request
)
{
return
parent
::
toArray
(
$request
);
//
return parent::toArray($request);
return
[
'success'
=>
$this
->
status
,
'message'
=>
$this
->
message
,
...
...
This diff is collapsed.
Click to expand it.
routes/api.php
View file @
fa9634c8
...
...
@@ -21,3 +21,6 @@ Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
Route
::
get
(
'/agama/listagamabaru'
,
[
ControllerApiAgama
::
class
,
'index'
]);
Route
::
get
(
'/agama/detailagamabaru/{id}'
,
[
ControllerApiAgama
::
class
,
'show'
]);
Route
::
post
(
'/agama/addagamabaru'
,
[
ControllerApiAgama
::
class
,
'store'
]);
Route
::
put
(
'/agama/updateagamabaru/{id}'
,
[
ControllerApiAgama
::
class
,
'update'
]);
Route
::
delete
(
'/agama/deleteagamabaru/{id}'
,
[
ControllerApiAgama
::
class
,
'destroy'
]);
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help