Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Habib Shohiburrotib
project-sarpras
Commits
57314153
Commit
57314153
authored
1 year ago
by
Ghani Albaba
Browse files
Options
Download
Plain Diff
Merge branch 'ghani'
parents
4cf8cc27
a7e383f1
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
cobapeminjaman/app/Http/Controllers/CRUD/AlatController.php
+70
-58
cobapeminjaman/app/Http/Controllers/CRUD/AlatController.php
cobapeminjaman/app/Http/Controllers/CRUD/BhpController.php
+78
-38
cobapeminjaman/app/Http/Controllers/CRUD/BhpController.php
cobapeminjaman/app/Http/Controllers/CRUD/RuangController.php
+67
-64
cobapeminjaman/app/Http/Controllers/CRUD/RuangController.php
cobapeminjaman/app/Models/alat.php
+1
-1
cobapeminjaman/app/Models/alat.php
cobapeminjaman/app/Models/bhp.php
+1
-1
cobapeminjaman/app/Models/bhp.php
cobapeminjaman/app/Models/ruang.php
+1
-1
cobapeminjaman/app/Models/ruang.php
cobapeminjaman/composer.json
+1
-0
cobapeminjaman/composer.json
cobapeminjaman/composer.lock
+332
-262
cobapeminjaman/composer.lock
cobapeminjaman/config/image.php
+21
-0
cobapeminjaman/config/image.php
fe-sarpras/src/components/CRUD/Alat/AddAlat.vue
+160
-68
fe-sarpras/src/components/CRUD/Alat/AddAlat.vue
fe-sarpras/src/components/CRUD/Alat/AllAlat.vue
+1
-1
fe-sarpras/src/components/CRUD/Alat/AllAlat.vue
fe-sarpras/src/components/CRUD/Alat/UpdateAlat.vue
+66
-85
fe-sarpras/src/components/CRUD/Alat/UpdateAlat.vue
fe-sarpras/src/components/CRUD/BHP/AddBhp.vue
+3
-3
fe-sarpras/src/components/CRUD/BHP/AddBhp.vue
fe-sarpras/src/components/CRUD/BHP/AllBhp.vue
+1
-1
fe-sarpras/src/components/CRUD/BHP/AllBhp.vue
fe-sarpras/src/components/CRUD/Ruang/AddRuang.vue
+3
-3
fe-sarpras/src/components/CRUD/Ruang/AddRuang.vue
fe-sarpras/src/components/CRUD/Ruang/AllRuang.vue
+1
-1
fe-sarpras/src/components/CRUD/Ruang/AllRuang.vue
fe-sarpras/src/main.js
+2
-0
fe-sarpras/src/main.js
with
809 additions
and
587 deletions
+809
-587
cobapeminjaman/app/Http/Controllers/CRUD/AlatController.php
View file @
57314153
<?php
namespace
App\Http\Controllers\CRUD
;
use
Illuminate\Http\Request
;
...
...
@@ -7,9 +8,8 @@ use App\Models\Alat;
use
Illuminate\Support\Facades\Storage
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Support\Facades\File
;
use
Intervention\Image\Facades\Image
;
use
Illuminate\Support\Str
;
use
Illuminate\Support\Facades\Validator
;
use
Illuminate\Support\Str
;
class
AlatController
extends
Controller
{
...
...
@@ -21,13 +21,45 @@ class AlatController extends Controller
public
function
store
(
Request
$request
)
{
$requestData
=
$request
->
all
();
$fileName
=
time
()
.
$request
->
file
(
'id_foto_alat'
)
->
getClientOriginalName
();
$path
=
$request
->
file
(
'id_foto_alat'
)
->
storeAs
(
'alat'
,
$fileName
,
'public'
);
$newpath
=
str_replace
(
'alat/'
,
''
,
$path
);
$requestData
[
"id_foto_alat"
]
=
$newpath
;
Alat
::
create
(
$requestData
);
return
response
()
->
json
([
'message'
=>
'Alat berhasil disimpan'
],
201
);
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'nama_alat'
=>
'required'
,
'tipe'
=>
'required'
,
'stok'
=>
'required'
,
'no_inventaris'
=>
'required'
,
'kondisi'
=>
'required'
,
'foto_alat'
=>
'required'
,
]);
// response error validation
if
(
$validator
->
fails
())
{
return
response
()
->
json
(
$validator
->
errors
(),
400
);
}
if
(
$request
->
hasFile
(
'foto_alat'
))
{
$file
=
$request
->
file
(
'foto_alat'
);
$uuid
=
(
string
)
Str
::
uuid
();
$extension
=
$file
->
getClientOriginalExtension
();
$filename
=
$uuid
.
'.'
.
$extension
;
$path
=
$file
->
storeAs
(
'public/alat'
,
$filename
);
$newpath
=
'storage/alat/'
.
$filename
;
}
else
{
return
response
()
->
json
([
'success'
=>
false
,
'message'
=>
'Foto alat tidak ditemukan'
],
400
);
}
$alat
=
Alat
::
create
([
'nama_alat'
=>
$request
->
nama_alat
,
'tipe'
=>
$request
->
tipe
,
'stok'
=>
$request
->
stok
,
'no_inventaris'
=>
$request
->
no_inventaris
,
'kondisi'
=>
$request
->
kondisi
,
'foto_alat'
=>
$newpath
,
]);
return
response
()
->
json
([
'message'
=>
'Alat berhasil ditambahkan'
]);
}
public
function
show
(
$id
)
...
...
@@ -40,13 +72,23 @@ class AlatController extends Controller
}
}
public
function
update
(
Request
$request
,
$id
)
{
$db_alat
=
Alat
::
findOrFail
(
$id
);
$id_foto_alat
=
$request
->
id_foto_alat
;
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'nama_alat'
=>
'required'
,
'tipe'
=>
'required'
,
'stok'
=>
'required'
,
'no_inventaris'
=>
'required'
,
'kondisi'
=>
'required'
,
'foto_alat'
=>
'image'
,
]);
if
(
$validator
->
fails
())
{
return
response
()
->
json
(
$validator
->
errors
(),
400
);
}
$data
=
[
'nama_alat'
=>
$request
->
nama_alat
,
...
...
@@ -55,61 +97,31 @@ class AlatController extends Controller
'no_inventaris'
=>
$request
->
no_inventaris
,
'kondisi'
=>
$request
->
kondisi
,
];
if
(
$id_foto_alat
!=
""
)
{
$data
[
'id_foto_alat'
]
=
$id_foto_alat
;
if
(
$request
->
hasFile
(
'foto_alat'
))
{
if
(
File
::
exists
(
public_path
(
$db_alat
->
foto_alat
)))
{
File
::
delete
(
public_path
(
$db_alat
->
foto_alat
));
}
$file
=
$request
->
file
(
'foto_alat'
);
$uuid
=
(
string
)
Str
::
uuid
();
$extension
=
$file
->
getClientOriginalExtension
();
$filename
=
$uuid
.
'.'
.
$extension
;
$path
=
$file
->
storeAs
(
'public/alat'
,
$filename
);
$newpath
=
'storage/alat/'
.
$filename
;
$data
[
'foto_alat'
]
=
$newpath
;
}
$db_alat
->
update
(
$data
);
return
response
()
->
json
([
'message'
=>
'Alat berhasil diupdate'
],
200
);
}
// public function update(Request $request, $id)
// {
// $request->validate([
// 'nama_alat' => 'required',
// 'tipe' => 'required',
// 'stok' => 'required',
// 'no_inventaris' => 'required',
// 'kondisi' => 'required',
// ]);
// $alat = Alat::findOrFail($id);
// if ($request->hasFile('id_foto_alat')) {
// $fileName = time().$request->file('id_foto_alat')->getClientOriginalName();
// $path = $request->file('id_foto_alat')->storeAs('public/alat', $fileName);
// $newpath = str_replace('public/', '', $path);
// $alat->id_foto_alat = $newpath;
// $alat->save();
// }
// if (!$alat) {
// return response()->json(['message' => 'Alat tidak ditemukan'], 404);
// }
// $alat->update([
// 'nama_alat' => $request->input('nama_alat'),
// 'tipe' => $request->input('tipe'),
// 'stok' => $request->input('stok'),
// 'no_inventaris' => $request->input('no_inventaris'),
// 'kondisi' => $request->input('kondisi'),
// ]);
// return response()->json(['message' => 'Alat berhasil diperbarui']);
// }
public
function
destroy
(
$id
)
public
function
destroy
(
$id
)
{
$alat
=
Alat
::
findOrFail
(
$id
);
if
(
File
::
exists
(
$alat
->
id_
foto_alat
)){
File
::
delete
(
$alat
->
id_
foto_alat
);
if
(
File
::
exists
(
$alat
->
foto_alat
)){
File
::
delete
(
$alat
->
foto_alat
);
}
if
(
!
$alat
)
{
...
...
This diff is collapsed.
Click to expand it.
cobapeminjaman/app/Http/Controllers/CRUD/BhpController.php
View file @
57314153
...
...
@@ -8,6 +8,8 @@ use Illuminate\Support\Facades\Storage;
use
App\Http\Controllers\Controller
;
use
Illuminate\Support\Facades\File
;
use
Illuminate\Support\Facades\Validator
;
use
Illuminate\Support\Str
;
class
BhpController
extends
Controller
{
...
...
@@ -19,13 +21,41 @@ class BhpController extends Controller
public
function
store
(
Request
$request
)
{
$requestData
=
$request
->
all
();
$fileName
=
time
()
.
$request
->
file
(
'id_foto_bhp'
)
->
getClientOriginalName
();
$path
=
$request
->
file
(
'id_foto_bhp'
)
->
storeAs
(
'bhp'
,
$fileName
,
'public'
);
$newpath
=
str_replace
(
'bhp/'
,
''
,
$path
);
$requestData
[
"id_foto_bhp"
]
=
$newpath
;
Bhp
::
create
(
$requestData
);
return
response
()
->
json
([
'message'
=>
'Bhp berhasil disimpan'
],
201
);
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'nama_bhp'
=>
'required'
,
'tipe'
=>
'required'
,
'stok'
=>
'required'
,
'no_inventaris'
=>
'required'
,
'foto_bhp'
=>
'required'
,
]);
if
(
$validator
->
fails
())
{
return
response
()
->
json
(
$validator
->
errors
(),
400
);
}
if
(
$request
->
hasFile
(
'foto_bhp'
))
{
$file
=
$request
->
file
(
'foto_bhp'
);
$uuid
=
(
string
)
Str
::
uuid
();
$extension
=
$file
->
getClientOriginalExtension
();
$filename
=
$uuid
.
'.'
.
$extension
;
$path
=
$file
->
storeAs
(
'public/bhp'
,
$filename
);
$newpath
=
'storage/bhp/'
.
$filename
;
}
else
{
return
response
()
->
json
([
'success'
=>
false
,
'message'
=>
'Foto bhp tidak ditemukan'
],
400
);
}
$bhp
=
Bhp
::
create
([
'nama_bhp'
=>
$request
->
nama_bhp
,
'tipe'
=>
$request
->
tipe
,
'stok'
=>
$request
->
stok
,
'no_inventaris'
=>
$request
->
no_inventaris
,
'foto_bhp'
=>
$newpath
,
]);
return
response
()
->
json
([
'message'
=>
'Bhp berhasil ditambahkan'
]);
}
public
function
show
(
$id
)
...
...
@@ -40,43 +70,53 @@ class BhpController extends Controller
public
function
update
(
Request
$request
,
$id
)
{
$request
->
validate
([
'nama_bhp'
=>
'required'
,
'tipe'
=>
'required'
,
'stok'
=>
'required|integer'
,
'no_inventaris'
=>
'required'
,
]);
$db_bhp
=
Bhp
::
findOrFail
(
$id
);
$bhp
=
Bhp
::
find
(
$id
);
if
(
!
$bhp
)
{
return
response
()
->
json
([
'message'
=>
'Bhp tidak ditemukan'
],
404
);
}
$bhp
->
update
([
'nama_bhp'
=>
$request
->
input
(
'nama_bhp'
),
'tipe'
=>
$request
->
input
(
'tipe'
),
'stok'
=>
$request
->
input
(
'stok'
),
'no_inventaris'
=>
$request
->
input
(
'no_inventaris'
),
]);
if
(
$request
->
hasFile
(
'id_foto_bhp'
))
{
$fileName
=
time
()
.
$request
->
file
(
'id_foto_bhp'
)
->
getClientOriginalName
();
$path
=
$request
->
file
(
'id_foto_bhp'
)
->
storeAs
(
'public/bhp'
,
$fileName
);
$newpath
=
str_replace
(
'public/'
,
''
,
$path
);
$bhp
->
id_foto_bhp
=
$newpath
;
$bhp
->
save
();
}
return
response
()
->
json
([
'message'
=>
'Bhp berhasil diperbarui'
]);
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'nama_bhp'
=>
'required'
,
'tipe'
=>
'required'
,
'stok'
=>
'required'
,
'no_inventaris'
=>
'required'
,
'foto_bhp'
=>
'image'
,
]);
if
(
$validator
->
fails
())
{
return
response
()
->
json
(
$validator
->
errors
(),
400
);
}
$data
=
[
'nama_bhp'
=>
$request
->
nama_bhp
,
'tipe'
=>
$request
->
tipe
,
'stok'
=>
$request
->
stok
,
'no_inventaris'
=>
$request
->
no_inventaris
,
];
if
(
$request
->
hasFile
(
'foto_bhp'
))
{
if
(
File
::
exists
(
public_path
(
$db_bhp
->
foto_bhp
)))
{
File
::
delete
(
public_path
(
$db_bhp
->
foto_bhp
));
}
$file
=
$request
->
file
(
'foto_bhp'
);
$uuid
=
(
string
)
Str
::
uuid
();
$extension
=
$file
->
getClientOriginalExtension
();
$filename
=
$uuid
.
'.'
.
$extension
;
$path
=
$file
->
storeAs
(
'public/bhp'
,
$filename
);
$newpath
=
'storage/bhp/'
.
$filename
;
$data
[
'foto_bhp'
]
=
$newpath
;
}
$db_bhp
->
update
(
$data
);
return
response
()
->
json
([
'message'
=>
'bhp berhasil diupdate'
],
200
);
}
public
function
destroy
(
$id
)
{
$bhp
=
Bhp
::
findOrFail
(
$id
);
if
(
File
::
exists
(
$bhp
->
id_
foto_bhp
)){
File
::
delete
(
$bhp
->
id_
foto_bhp
);
if
(
File
::
exists
(
$bhp
->
foto_bhp
)){
File
::
delete
(
$bhp
->
foto_bhp
);
}
if
(
!
$bhp
)
{
...
...
This diff is collapsed.
Click to expand it.
cobapeminjaman/app/Http/Controllers/CRUD/RuangController.php
View file @
57314153
...
...
@@ -9,6 +9,8 @@ use Illuminate\Support\Facades\Storage;
use
App\Http\Controllers\Controller
;
use
Illuminate\Support\Facades\File
;
use
Illuminate\Support\Facades\Validator
;
use
Illuminate\Support\Str
;
class
RuangController
extends
Controller
{
...
...
@@ -20,44 +22,43 @@ class RuangController extends Controller
public
function
store
(
Request
$request
)
{
$requestData
=
$request
->
all
();
$fileName
=
time
()
.
$request
->
file
(
'id_foto_ruang'
)
->
getClientOriginalName
();
$path
=
$request
->
file
(
'id_foto_ruang'
)
->
storeAs
(
'ruang'
,
$fileName
,
'public'
);
$newpath
=
str_replace
(
'ruang/'
,
''
,
$path
);
$requestData
[
"id_foto_ruang"
]
=
$newpath
;
Ruang
::
create
(
$requestData
);
return
response
()
->
json
([
'message'
=>
'Ruang berhasil disimpan'
],
201
);
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'nama_ruang'
=>
'required'
,
'ketersediaan_ruang'
=>
'required'
,
'kapasitas'
=>
'required'
,
'fasilitas'
=>
'required'
,
'foto_ruang'
=>
'required'
,
]);
// $request->validate([
// 'nama_ruang' => 'required',
// // 'id_foto_ruang' => 'required',
// 'ketersediaan_ruang' => 'required',
// 'kapasitas' => 'required|integer',
// 'fasilitas' => 'required',
// 'id_foto_ruang' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
// ]);
// response error validation
if
(
$validator
->
fails
())
{
return
response
()
->
json
(
$validator
->
errors
(),
400
);
}
// $ruang = new Ruang();
// $ruang->nama_ruang = $request->nama_ruang;
// // $ruang->id_foto_ruang = $request->id_foto_ruang;
// $ruang->ketersediaan_ruang = $request->ketersediaan_ruang;
// $ruang->kapasitas = $request->kapasitas;
// $ruang->fasilitas = $request->fasilitas;
if
(
$request
->
hasFile
(
'foto_ruang'
))
{
$file
=
$request
->
file
(
'foto_ruang'
);
$uuid
=
(
string
)
Str
::
uuid
();
$extension
=
$file
->
getClientOriginalExtension
();
$filename
=
$uuid
.
'.'
.
$extension
;
$path
=
$file
->
storeAs
(
'public/ruang'
,
$filename
);
$newpath
=
'storage/ruang/'
.
$filename
;
}
else
{
return
response
()
->
json
([
'success'
=>
false
,
'message'
=>
'Foto ruang tidak ditemukan'
],
400
);
}
// if ($request->hasFile('id_foto_ruang')) {
// $imagePath = $request->file('id_foto_ruang')->store('public/ruang');
// $ruang->foto_ruang = basename($imagePath);
// }
$ruang
=
ruang
::
create
([
'nama_ruang'
=>
$request
->
nama_ruang
,
'ketersediaan_ruang'
=>
$request
->
ketersediaan_ruang
,
'kapasitas'
=>
$request
->
kapasitas
,
'fasilitas'
=>
$request
->
fasilitas
,
'foto_ruang'
=>
$newpath
,
]);
// $ruang->save(
);
return
response
()
->
json
([
'message'
=>
'ruang berhasil ditambahkan'
]
);
// return response()->json(['message' => 'Ruang berhasil disimpan'], 201);
}
public
function
show
(
$id
)
...
...
@@ -73,51 +74,53 @@ class RuangController extends Controller
public
function
update
(
Request
$request
,
$id
)
{
// $ruang = $this->Ruang->find($id);
// $ruang->update($request->all());
// return $ruang;
$db_ruang
=
ruang
::
findOrFail
(
$id
);
$request
->
v
al
idate
(
[
'nama_ruang'
=>
'required'
,
$validator
=
Validator
::
make
(
$request
->
al
l
(),
[
'nama_ruang'
=>
'required'
,
'ketersediaan_ruang'
=>
'required'
,
'kapasitas'
=>
'required'
,
'fasilitas'
=>
'required'
,
'foto_ruang'
=>
'image'
,
]);
$ruang
=
Ruang
::
find
(
$id
);
if
(
!
$ruang
)
{
return
response
()
->
json
([
'message'
=>
'Ruang tidak ditemukan'
],
404
);
if
(
$validator
->
fails
())
{
return
response
()
->
json
(
$validator
->
errors
(),
400
);
}
// Proses update data kecuali gambar
$ruang
->
update
([
'nama_ruang'
=>
$request
->
input
(
'nama_ruang'
),
'ketersediaan_ruang'
=>
$request
->
input
(
'ketersediaan_ruang'
),
'kapasitas'
=>
$request
->
input
(
'kapasitas'
),
'fasilitas'
=>
$request
->
input
(
'fasilitas'
),
]);
// Proses update gambar jika ada
if
(
$request
->
hasFile
(
'id_foto_ruang'
))
{
$fileName
=
time
()
.
$request
->
file
(
'id_foto_ruang'
)
->
getClientOriginalName
();
$path
=
$request
->
file
(
'id_foto_ruang'
)
->
storeAs
(
'public/ruang'
,
$fileName
);
$newpath
=
str_replace
(
'public/'
,
''
,
$path
);
// Update kolom id_foto_ruang di database
$ruang
->
id_foto_ruang
=
$newpath
;
$ruang
->
save
();
$data
=
[
'nama_ruang'
=>
$request
->
nama_ruang
,
'ketersediaan_ruang'
=>
$request
->
ketersediaan_ruang
,
'kapasitas'
=>
$request
->
kapasitas
,
'fasilitas'
=>
$request
->
fasilitas
,
];
if
(
$request
->
hasFile
(
'foto_ruang'
))
{
if
(
File
::
exists
(
public_path
(
$db_ruang
->
foto_ruang
)))
{
File
::
delete
(
public_path
(
$db_ruang
->
foto_ruang
));
}
$file
=
$request
->
file
(
'foto_ruang'
);
$uuid
=
(
string
)
Str
::
uuid
();
$extension
=
$file
->
getClientOriginalExtension
();
$filename
=
$uuid
.
'.'
.
$extension
;
$path
=
$file
->
storeAs
(
'public/ruang'
,
$filename
);
$newpath
=
'storage/ruang/'
.
$filename
;
$data
[
'foto_ruang'
]
=
$newpath
;
}
return
response
()
->
json
([
'message'
=>
'Ruang berhasil diperbarui'
]);
$db_ruang
->
update
(
$data
);
return
response
()
->
json
([
'message'
=>
'ruang berhasil diupdate'
],
200
);
}
public
function
destroy
(
$id
)
{
$ruang
=
Ruang
::
findOrFail
(
$id
);
if
(
File
::
exists
(
$ruang
->
id_
foto_ruang
)){
File
::
delete
(
$ruang
->
id_
foto_ruang
);
if
(
File
::
exists
(
$ruang
->
foto_ruang
)){
File
::
delete
(
$ruang
->
foto_ruang
);
}
if
(
!
$ruang
)
{
...
...
This diff is collapsed.
Click to expand it.
cobapeminjaman/app/Models/alat.php
View file @
57314153
...
...
@@ -12,6 +12,6 @@ class Alat extends Model
protected
$primaryKey
=
'id_alat'
;
protected
$fillable
=
[
'
id_
foto_alat'
,
'nama_alat'
,
'tipe'
,
'stok'
,
'no_inventaris'
,
'kondisi'
,
'foto_alat'
,
'nama_alat'
,
'tipe'
,
'stok'
,
'no_inventaris'
,
'kondisi'
,
];
}
This diff is collapsed.
Click to expand it.
cobapeminjaman/app/Models/bhp.php
View file @
57314153
...
...
@@ -12,6 +12,6 @@ class Bhp extends Model
protected
$primaryKey
=
'id_bhp'
;
protected
$fillable
=
[
'
id_
foto_bhp'
,
'nama_bhp'
,
'tipe'
,
'stok'
,
'no_inventaris'
,
'foto_bhp'
,
'nama_bhp'
,
'tipe'
,
'stok'
,
'no_inventaris'
,
];
}
This diff is collapsed.
Click to expand it.
cobapeminjaman/app/Models/ruang.php
View file @
57314153
...
...
@@ -12,6 +12,6 @@ class Ruang extends Model
protected
$primaryKey
=
'id_ruang'
;
protected
$fillable
=
[
'
id_
foto_ruang'
,
'nama_ruang'
,
'ketersediaan_ruang'
,
'kapasitas'
,
'fasilitas'
,
'foto_ruang'
,
'nama_ruang'
,
'ketersediaan_ruang'
,
'kapasitas'
,
'fasilitas'
,
];
}
This diff is collapsed.
Click to expand it.
cobapeminjaman/composer.json
View file @
57314153
...
...
@@ -8,6 +8,7 @@
"php"
:
"^8.1"
,
"guzzlehttp/guzzle"
:
"^7.2"
,
"intervention/image"
:
"^3.6"
,
"intervention/image-laravel"
:
"^1.2"
,
"laravel/framework"
:
"^10.0"
,
"laravel/sanctum"
:
"^3.2"
,
"laravel/tinker"
:
"^2.8"
...
...
This diff is collapsed.
Click to expand it.
cobapeminjaman/composer.lock
View file @
57314153
This diff is collapsed.
Click to expand it.
cobapeminjaman/config/image.php
0 → 100644
View file @
57314153
<?php
return
[
/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports “GD Library” and “Imagick” to process images
| internally. Depending on your PHP setup, you can choose one of them.
|
| Included options:
| - \Intervention\Image\Drivers\Gd\Driver::class
| - \Intervention\Image\Drivers\Imagick\Driver::class
|
*/
'driver'
=>
\
Intervention\Image\Drivers\Gd\Driver
::
class
];
This diff is collapsed.
Click to expand it.
fe-sarpras/src/components/CRUD/Alat/AddAlat.vue
View file @
57314153
<
template
>
<div>
<
h2
class=
"
text-center mb-4"
>
Tambah Alat
</h2
>
<form
@
submit.prevent=
"submitForm
"
>
<div
class=
"
mb-3
"
>
<label
for=
"namaAlat"
class=
"form-label"
>
Nama Alat:
</label
>
<input
v-model=
"alatData.nama_alat"
type=
"text"
class=
"form-control"
id=
"namaAlat"
required
>
<
/div
>
<div
class=
"container mt-5"
>
<
div
class=
"
row"
>
<div
class=
"col-md-12
"
>
<div
class=
"
card border-0 rounded shadow
"
>
<div
class=
"card-body"
>
<h4>
TAMBAH ALAT
</h4
>
<
hr
/
>
<div
class=
"mb-3"
>
<label
for=
"tipe"
class=
"form-label"
>
Tipe:
</label>
<input
v-model=
"alatData.tipe"
type=
"text"
class=
"form-control"
id=
"tipe"
required
>
</div>
<form
@
submit.prevent=
"store"
>
<div
class=
"form-group"
>
<label
for=
"nama_alat"
class=
"font-weight-bold"
>
Nama Alat
</label>
<input
type=
"text"
class=
"form-control"
v-model=
"post.nama_alat"
placeholder=
"Masukkan nama alat"
/>
<div
class=
"mb-3"
>
<label
for=
"stok"
class=
"form-label"
>
Stok:
</label>
<input
v-model=
"alatData.stok"
type=
"number"
class=
"form-control"
id=
"stok"
required
>
</div>
<!-- validation -->
<div
v-if=
"validation.nama_alat"
class=
"mt-2 alert alert-danger"
>
{{
validation
.
nama_alat
[
0
]
}}
</div>
</div>
<div
class=
"
mb-3
"
>
<label
for=
"
noInventaris"
class=
"form-label"
>
No Inventaris:
</label>
<input
v-model=
"alatData.no_inventaris"
type=
"text"
class=
"form-control"
id=
"noInventaris"
required
>
</div>
<div
class=
"mb-3"
>
<label
for=
"kondisi"
class=
"form-label"
>
Kondisi:
</label>
<input
v-mo
de
l
=
"
alatData.kondisi"
t
y
pe
=
"text"
class=
"form-control"
id=
"kondisi"
required
>
</div
>
<div
class=
"
form-group
"
>
<label
for=
"
tipe"
class=
"font-weight-bold"
>
Tipe
</label>
<input
type=
"text"
class=
"form-control"
v-model=
"post.tipe"
placehol
de
r
=
"
Masukkan
t
i
pe
alat"
/
>
<div
class=
"mb-3"
>
<label
for=
"idFotoAlat"
class=
"form-label"
>
ID Foto Alat:
</label>
<input
type=
"file"
ref=
"fileInput"
@
change=
"handleFileUpload"
class=
"form-control"
accept=
"image/*"
required
>
</div>
<!-- validation -->
<div
v-if=
"validation.tipe"
class=
"mt-2 alert alert-danger"
>
{{
validation
.
tipe
[
0
]
}}
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"stok"
class=
"font-weight-bold"
>
Stok
</label>
<input
type=
"number"
class=
"form-control"
v-model=
"post.stok"
placeholder=
"Masukkan jumlah stok alat"
/>
<!-- validation -->
<div
v-if=
"validation.stok"
class=
"mt-2 alert alert-danger"
>
{{
validation
.
stok
[
0
]
}}
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"no_inventaris"
class=
"font-weight-bold"
>
No Inventaris
</label>
<input
type=
"text"
class=
"form-control"
v-model=
"post.no_inventaris"
placeholder=
"Masukkan nomor inventaris alat"
/>
<!-- validation -->
<div
v-if=
"validation.no_inventaris"
class=
"mt-2 alert alert-danger"
>
{{
validation
.
no_inventaris
[
0
]
}}
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"kondisi"
class=
"font-weight-bold"
>
Kondisi
</label>
<input
type=
"text"
class=
"form-control"
v-model=
"post.kondisi"
placeholder=
"Masukkan kondisi alat"
/>
<!-- validation -->
<div
v-if=
"validation.kondisi"
class=
"mt-2 alert alert-danger"
>
{{
validation
.
kondisi
[
0
]
}}
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"foto_alat"
class=
"font-weight-bold"
>
Foto Alat
</label>
<input
type=
"file"
class=
"form-control"
@
change=
"handleFileUpload"
/>
<button
type=
"submit"
class=
"btn btn-success"
>
Tambah Alat
</button>
</form>
<!-- validation -->
<div
v-if=
"validation.foto_alat"
class=
"mt-2 alert alert-danger"
>
{{
validation
.
foto_alat
[
0
]
}}
</div>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
SIMPAN
</button>
<router-link
:to=
"
{ name: 'allAlat' }" class="btn btn-secondary"
>CANCEL
</router-link
>
</form>
</div>
</div>
</div>
</div>
</div>
</
template
>
<
script
>
import
axios
from
'
axios
'
;
import
{
reactive
,
ref
}
from
"
vue
"
;
import
{
useRouter
}
from
"
vue-router
"
;
import
axios
from
"
axios
"
;
export
default
{
data
()
{
return
{
alatData
:
{
nama_alat
:
''
,
tipe
:
''
,
stok
:
''
,
no_inventaris
:
''
,
kondisi
:
''
,
id_foto_alat
:
null
,
// Updated field for image upload
},
};
},
methods
:
{
handleFileUpload
()
{
const
file
=
this
.
$refs
.
fileInput
.
files
[
0
];
this
.
alatData
.
id_foto_alat
=
file
;
// Assigning file to id_foto_alat field
},
async
submitForm
()
{
try
{
const
formData
=
new
FormData
();
formData
.
append
(
'
nama_alat
'
,
this
.
alatData
.
nama_alat
);
formData
.
append
(
'
tipe
'
,
this
.
alatData
.
tipe
);
formData
.
append
(
'
stok
'
,
this
.
alatData
.
stok
);
formData
.
append
(
'
no_inventaris
'
,
this
.
alatData
.
no_inventaris
);
formData
.
append
(
'
kondisi
'
,
this
.
alatData
.
kondisi
);
formData
.
append
(
'
id_foto_alat
'
,
this
.
alatData
.
id_foto_alat
);
// Updated field name
await
axios
.
post
(
'
/api/alats/add-alats
'
,
formData
,
{
setup
()
{
// Initial state alat
const
post
=
reactive
({
nama_alat
:
""
,
tipe
:
""
,
stok
:
""
,
no_inventaris
:
""
,
kondisi
:
""
,
foto_alat
:
null
,
});
// State validation
const
validation
=
ref
([]);
// Vue router
const
router
=
useRouter
();
// Handle file upload
function
handleFileUpload
(
event
)
{
post
.
foto_alat
=
event
.
target
.
files
[
0
];
}
// Method store
function
store
()
{
let
formData
=
new
FormData
();
formData
.
append
(
'
nama_alat
'
,
post
.
nama_alat
);
formData
.
append
(
'
tipe
'
,
post
.
tipe
);
formData
.
append
(
'
stok
'
,
post
.
stok
);
formData
.
append
(
'
no_inventaris
'
,
post
.
no_inventaris
);
formData
.
append
(
'
kondisi
'
,
post
.
kondisi
);
formData
.
append
(
'
foto_alat
'
,
post
.
foto_alat
);
axios
.
post
(
'
/api/alats/add-alats
'
,
formData
,
{
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
,
},
})
.
then
(()
=>
{
// Redirect ke alat index
router
.
push
(
'
/admin/all-alats
'
);
})
.
catch
((
error
)
=>
{
// Assign state validation with error
validation
.
value
=
error
.
response
.
data
;
});
}
console
.
log
(
'
Alat berhasil ditambahkan!
'
);
alert
(
'
Alat berhasil ditambahkan.
'
);
this
.
$router
.
push
(
'
/admin/all-alat
'
);
// Redirect to all-alat page
}
catch
(
error
)
{
console
.
error
(
'
Error adding alat:
'
,
error
);
alert
(
'
Gagal menambahkan alat. Silakan cek inputan Anda dan coba lagi.
'
);
}
}
,
// Return
return
{
post
,
validation
,
router
,
store
,
handleFileUpload
,
}
;
},
};
</
script
>
<
style
scoped
>
/* Custom styles */
<
style
>
body
{
background
:
lightgray
;
}
</
style
>
This diff is collapsed.
Click to expand it.
fe-sarpras/src/components/CRUD/Alat/AllAlat.vue
View file @
57314153
...
...
@@ -29,7 +29,7 @@
<td>
{{
alat
.
kondisi
}}
</td>
<td>
<img
:src=
"getImageUrl(alat.
id_
foto_alat)"
:src=
"getImageUrl(alat.foto_alat)"
style=
"max-width: 100px; max-height: 100px;"
class=
"img-thumbnail product-image"
alt=
"Alat Image"
...
...
This diff is collapsed.
Click to expand it.
fe-sarpras/src/components/CRUD/Alat/UpdateAlat.vue
View file @
57314153
<
template
>
<div>
<h2
class=
"text-center mb-4"
>
Edit Alat
</h2>
<form
@
submit.prevent=
"submitForm"
>
<div
class=
"mb-3"
>
<label
for=
"namaAlat"
class=
"form-label"
>
Nama Alat:
</label>
<input
v-model=
"alatData.nama_alat"
type=
"text"
class=
"form-control"
id=
"namaAlat"
required
>
</div>
<div
class=
"mb-3"
>
<label
for=
"tipe"
class=
"form-label"
>
Tipe:
</label>
<input
v-model=
"alatData.tipe"
type=
"text"
class=
"form-control"
id=
"tipe"
required
>
</div>
<div
class=
"mb-3"
>
<label
for=
"stok"
class=
"form-label"
>
Stok:
</label>
<input
v-model=
"alatData.stok"
type=
"number"
class=
"form-control"
id=
"stok"
required
>
</div>
<div
class=
"mb-3"
>
<label
for=
"noInventaris"
class=
"form-label"
>
No Inventaris:
</label>
<input
v-model=
"alatData.no_inventaris"
type=
"text"
class=
"form-control"
id=
"noInventaris"
required
>
</div>
<div
class=
"mb-3"
>
<label
for=
"kondisi"
class=
"form-label"
>
Kondisi:
</label>
<input
v-model=
"alatData.kondisi"
type=
"text"
class=
"form-control"
id=
"kondisi"
required
>
</div>
<div
class=
"mb-3"
>
<label
for=
"idFotoAlat"
class=
"form-label"
>
ID Foto Alat:
</label>
<input
type=
"file"
ref=
"fileInput"
@
change=
"handleFileUpload"
class=
"form-control"
accept=
"image/*"
>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
Simpan Perubahan
</button>
</form>
</div>
</
template
>
<
script
>
import
axios
from
'
axios
'
;
export
default
{
data
()
{
return
{
alatData
:
{
nama_alat
:
''
,
tipe
:
''
,
stok
:
''
,
no_inventaris
:
''
,
kondisi
:
''
,
id_foto_alat
:
''
,
},
};
},
methods
:
{
handleFileUpload
()
{
const
file
=
this
.
$refs
.
fileInput
.
files
[
0
];
this
.
motorData
.
image
=
file
;
<div>
<h1>
Update Alat
</h1>
<form
@
submit.prevent=
"submitForm"
>
<label
for=
"nama_alat"
>
Nama Alat:
</label>
<input
id=
"nama_alat"
v-model=
"alat.nama_alat"
/>
<label
for=
"tipe"
>
Tipe:
</label>
<input
id=
"tipe"
v-model=
"alat.tipe"
/>
<label
for=
"stok"
>
Stok:
</label>
<input
id=
"stok"
v-model=
"alat.stok"
/>
<label
for=
"no_inventaris"
>
No Inventaris:
</label>
<input
id=
"no_inventaris"
v-model=
"alat.no_inventaris"
/>
<label
for=
"kondisi"
>
Kondisi:
</label>
<input
id=
"kondisi"
v-model=
"alat.kondisi"
/>
<label
for=
"foto_alat"
>
Foto Alat:
</label>
<input
id=
"foto_alat"
type=
"file"
@
change=
"handleFileUpload"
/>
<button
type=
"submit"
>
Update
</button>
</form>
</div>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
alat
:
{
nama_alat
:
''
,
tipe
:
''
,
stok
:
''
,
no_inventaris
:
''
,
kondisi
:
''
,
foto_alat
:
null
,
},
};
},
async
mounted
()
{
const
id_alat
=
this
.
$route
.
params
.
id
;
const
response
=
await
this
.
$axios
.
get
(
`/api/alats/
${
id_alat
}
`
);
console
.
log
(
response
.
data
);
this
.
alat
=
response
.
data
;
},
methods
:
{
handleFileUpload
(
event
)
{
this
.
alat
.
foto_alat
=
event
.
target
.
files
[
0
];
},
async
submitForm
()
{
try
{
await
axios
.
put
(
`/api/alats/update/
${
this
.
alatData
.
id
}
`
,
this
.
alatData
);
async
submitForm
()
{
const
id_alat
=
this
.
$route
.
params
.
id
;
const
formData
=
new
FormData
();
Object
.
keys
(
this
.
alat
).
forEach
(
key
=>
{
formData
.
append
(
key
,
this
.
alat
[
key
]);
});
console
.
log
(
'
Alat berhasil diupdate!
'
);
alert
(
'
Alat berhasil diupdate.
'
);
this
.
$router
.
push
(
'
/admin/all-alat
'
);
}
catch
(
error
)
{
console
.
error
(
'
Error updating alat:
'
,
error
);
alert
(
'
Gagal mengupdate alat. Silakan cek inputan Anda dan coba lagi.
'
);
}
},
async
fetchDataAlat
(
id
)
{
try
{
const
response
=
await
axios
.
get
(
`/api/alats/
${
id
}
`
);
this
.
alatData
=
response
.
data
;
this
.
alatData
.
id
=
id
;
await
this
.
$axios
.
put
(
`/api/alats/update/
${
id_alat
}
`
,
formData
,
{
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
,
},
});
this
.
$router
.
push
({
name
:
'
allAlat
'
});
}
catch
(
error
)
{
console
.
error
(
'
Error
fetch
ing alat
data
:
'
,
error
);
console
.
error
(
'
Error
updat
ing alat:
'
,
error
);
}
},
},
mounted
()
{
const
id
=
this
.
$route
.
params
.
id
;
this
.
fetchDataAlat
(
id
);
},
};
</
script
>
<
style
scoped
>
/* Custom styles */
</
style
>
},
};
</
script
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
fe-sarpras/src/components/CRUD/BHP/AddBhp.vue
View file @
57314153
...
...
@@ -43,14 +43,14 @@ export default {
tipe
:
''
,
stok
:
''
,
no_inventaris
:
''
,
id_
foto_bhp
:
null
,
// Updated field for image upload
foto_bhp
:
null
,
// Updated field for image upload
},
};
},
methods
:
{
handleFileUpload
()
{
const
file
=
this
.
$refs
.
fileInput
.
files
[
0
];
this
.
bhpData
.
id_
foto_bhp
=
file
;
// Assigning file to
id_
foto_bhp field
this
.
bhpData
.
foto_bhp
=
file
;
// Assigning file to foto_bhp field
},
async
submitForm
()
{
try
{
...
...
@@ -59,7 +59,7 @@ export default {
formData
.
append
(
'
tipe
'
,
this
.
bhpData
.
tipe
);
formData
.
append
(
'
stok
'
,
this
.
bhpData
.
stok
);
formData
.
append
(
'
no_inventaris
'
,
this
.
bhpData
.
no_inventaris
);
formData
.
append
(
'
id_
foto_bhp
'
,
this
.
bhpData
.
id_
foto_bhp
);
// Updated field name
formData
.
append
(
'
foto_bhp
'
,
this
.
bhpData
.
foto_bhp
);
// Updated field name
await
axios
.
post
(
'
/api/bhps/add-bhps
'
,
formData
,
{
headers
:
{
...
...
This diff is collapsed.
Click to expand it.
fe-sarpras/src/components/CRUD/BHP/AllBhp.vue
View file @
57314153
...
...
@@ -26,7 +26,7 @@
<td>
{{
bhp
.
no_inventaris
}}
</td>
<td>
<img
:src=
"getImageUrl(bhp.
id_
foto_bhp)"
:src=
"getImageUrl(bhp.foto_bhp)"
style=
"max-width: 100px; max-height: 100px;"
class=
"img-thumbnail room-image"
alt=
"Ruang Image"
...
...
This diff is collapsed.
Click to expand it.
fe-sarpras/src/components/CRUD/Ruang/AddRuang.vue
View file @
57314153
...
...
@@ -43,14 +43,14 @@ export default {
ketersediaan_ruang
:
''
,
kapasitas
:
''
,
fasilitas
:
''
,
id_
foto_ruang
:
null
,
// Updated field for image upload
foto_ruang
:
null
,
// Updated field for image upload
},
};
},
methods
:
{
handleFileUpload
()
{
const
file
=
this
.
$refs
.
fileInput
.
files
[
0
];
this
.
ruangData
.
id_
foto_ruang
=
file
;
// Assigning file to
id_
foto_ruang field
this
.
ruangData
.
foto_ruang
=
file
;
// Assigning file to foto_ruang field
},
async
submitForm
()
{
try
{
...
...
@@ -59,7 +59,7 @@ export default {
formData
.
append
(
'
ketersediaan_ruang
'
,
this
.
ruangData
.
ketersediaan_ruang
);
formData
.
append
(
'
kapasitas
'
,
this
.
ruangData
.
kapasitas
);
formData
.
append
(
'
fasilitas
'
,
this
.
ruangData
.
fasilitas
);
formData
.
append
(
'
id_
foto_ruang
'
,
this
.
ruangData
.
id_
foto_ruang
);
// Updated field name
formData
.
append
(
'
foto_ruang
'
,
this
.
ruangData
.
foto_ruang
);
// Updated field name
await
axios
.
post
(
'
/api/ruangs/add-ruangs
'
,
formData
,
{
headers
:
{
...
...
This diff is collapsed.
Click to expand it.
fe-sarpras/src/components/CRUD/Ruang/AllRuang.vue
View file @
57314153
...
...
@@ -27,7 +27,7 @@
<td>
{{
ruang
.
fasilitas
}}
</td>
<td>
<img
:src=
"getImageUrl(ruang.
id_
foto_ruang)"
:src=
"getImageUrl(ruang.foto_ruang)"
style=
"max-width: 100px; max-height: 100px;"
class=
"img-thumbnail room-image"
alt=
"Ruang Image"
...
...
This diff is collapsed.
Click to expand it.
fe-sarpras/src/main.js
View file @
57314153
...
...
@@ -6,6 +6,7 @@ import 'bootstrap/dist/css/bootstrap.css';
import
'
bootstrap/dist/js/bootstrap.bundle
'
;
axios
.
defaults
.
baseURL
=
'
http://127.0.0.1:8000/
'
;
axios
.
defaults
.
headers
.
common
[
'
Authorization
'
]
=
'
Bearer
'
+
localStorage
.
getItem
(
'
token
'
);
axios
.
defaults
.
headers
.
post
[
'
Content-Type
'
]
=
'
application/json
'
;
...
...
@@ -15,5 +16,6 @@ axios.defaults.headers.delete['Content-Type'] = 'application/json';
const
app
=
createApp
(
App
)
app
.
config
.
globalProperties
.
$axios
=
axios
;
// Then set the global properties
app
.
use
(
router
);
app
.
mount
(
'
#app
'
)
// Finally, mount the app
\ No newline at end of file
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