Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Bagas Udi Sahsangka committed Nov 9, 2020
1 parent d4f66e1 commit 9eb59ce
Show file tree
Hide file tree
Showing 14 changed files with 181 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.yml]
[*.{yml,js,vue}]
indent_size = 2
2 changes: 1 addition & 1 deletion app/GateOut.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GateOut extends Model
'status'
];

protected $casts = ['kamera' => 'json'];
protected $casts = ['kamera' => 'json', 'jenis_kendaraan' => 'json'];

protected $appends = ['kameraList'];

Expand Down
19 changes: 13 additions & 6 deletions app/Http/Controllers/ManualOpenLogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\GateOut;
use App\Jobs\TakeSnapshotManualOpen;
use App\ManualOpenLog;
use App\User;
use Illuminate\Http\Request;
use GuzzleHttp\Client;

Expand Down Expand Up @@ -42,12 +43,18 @@ public function store(Request $request)
{
$request->validate([
'alasan' => 'required',
'gate_out_id' => 'required'
// 'password' => ['required', function($attribute, $value, $fail) {
// if (!password_verify($value, auth()->user()->password)) {
// $fail('Password yang Anda masukkan salah.');
// }
// }]
'gate_out_id' => 'required',
'password' => ['required', function ($attribute, $value, $fail) {
$admin = User::admin()->first();

if (!$admin) {
$fail('Tidak ada user admin');
}

if (!password_verify($value, $admin->password)) {
$fail('Password yang Anda masukkan salah.');
}
}]
], [], [
'alasan' => 'Alasan harus diisi',
'gate_out_id' => 'Gate keluar harus diisi'
Expand Down
17 changes: 16 additions & 1 deletion app/Http/Controllers/ParkingTransactionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function store(Request $request)

$parkingTransaction = ParkingTransaction::create($input);

TakeSnapshot::dispatchNow($parkingTransaction->gateOut, $parkingTransaction);
// TakeSnapshot::dispatchNow($parkingTransaction->gateOut, $parkingTransaction);

if (!$parkingTransaction->is_member && $request->ticket) {
PrintTicketOut::dispatchNow($parkingTransaction);
Expand Down Expand Up @@ -350,6 +350,17 @@ public function update(ParkingTransactionRequest $request, ParkingTransaction $p
];
}

public function takeSnapsot(Request $request, ParkingTransaction $parkingTransaction)
{
$request->validate([
'gate_out_id' => 'required|exists:gate_outs,id'
]);

TakeSnapshot::dispatchNow(GateOut::find($request->gate_out_id), $parkingTransaction);
return $parkingTransaction->snapshots;
}


public function printLastTransaction(Request $request)
{
$request->validate(['pos_id' => 'required|exists:pos,id']);
Expand Down Expand Up @@ -610,4 +621,8 @@ public function printReport(Request $request)
return response(['message' => 'GAGAL MENCETAK STRUK.' . $e->getMessage()], 500);
}
}

public function takeSnapshot(ParkingTransaction $parkingTransaction)
{
}
}
10 changes: 10 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,14 @@ public function setPasswordAttribute($value)
{
$this->attributes['password'] = bcrypt($value);
}

public function scopeAdmin($q)
{
return $q->where('role', 1);
}

public function scopeOperator($q)
{
return $q->where('role', 0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ChangeJenisKendaraanDiGateOutToJson extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('gate_outs', function (Blueprint $table) {
$table->dropColumn('jenis_kendaraan');
});

Schema::table('gate_outs', function (Blueprint $table) {
$table->json('jenis_kendaraan')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('gate_outs', function (Blueprint $table) {
});
}
}
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

41 changes: 28 additions & 13 deletions resources/js/components/FormBukaManual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<el-form label-position="left" label-width="200px">
<el-form-item
label="Alasan buka manual"
:class="formErrors.alasan ? 'is-error' : ''"
:class="{ 'is-error': formErrors.alasan }"
>
<el-input
autofocus
Expand All @@ -22,7 +22,10 @@
</div>
</el-form-item>

<el-form-item label="Gate Keluar">
<el-form-item
label="Gate Keluar"
:class="{ 'is-error': formErrors.gate_out_id }"
>
<el-select
v-model="formModel.gate_out_id"
style="width: 100%"
Expand All @@ -35,20 +38,32 @@
:value="gate.id"
></el-option>
</el-select>
<div class="el-form-item__error" v-if="formErrors.gate_out_id">
{{ formErrors.gate_out_id[0] }}
</div>
</el-form-item>

<!-- <el-form-item label="Masukkan password Anda" :class="formErrors.password ? 'is-error' : ''">
<el-input type="password" v-model="formModel.password" placeholder="Password"></el-input>
<div class="el-form-item__error" v-if="formErrors.password">{{formErrors.password[0]}}</div>
</el-form-item> -->
<el-form-item
label="Masukkan password Admin"
:class="formErrors.password ? 'is-error' : ''"
>
<el-input
type="password"
v-model="formModel.password"
placeholder="Password"
></el-input>
<div class="el-form-item__error" v-if="formErrors.password">
{{ formErrors.password[0] }}
</div>
</el-form-item>
</el-form>
<div slot="footer">
<el-button icon="el-icon-success" type="primary" @click="save"
>SIMPAN</el-button
>
<el-button icon="el-icon-error" type="info" @click="closeForm"
>BATAL</el-button
>
<el-button icon="el-icon-success" type="primary" @click="save">
SIMPAN
</el-button>
<el-button icon="el-icon-error" type="info" @click="closeForm">
BATAL
</el-button>
</div>
</el-dialog>
</template>
Expand Down Expand Up @@ -86,7 +101,7 @@ export default {
message: r.data.message,
type: "success",
});
$emit("open-gate", this.formModel.gate_out_id);
this.$emit("open-gate", this.formModel.gate_out_id);
this.closeForm();
})
.catch((e) => {
Expand Down
11 changes: 10 additions & 1 deletion resources/js/components/setting/GateOut.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@
min-width="150"
label="Jenis Kendaraan"
prop="jenis_kendaraan"
></el-table-column>
>
<template slot-scope="scope">
{{
scope.row.jenis_kendaraan
? scope.row.jenis_kendaraan.join(", ")
: ""
}}
</template>
</el-table-column>
<el-table-column
min-width="100"
label="Device"
Expand Down Expand Up @@ -126,6 +134,7 @@ export default {
components: { FormGateOut },
mounted() {
this.requestData();
this.$store.commit("getJenisKendaraanList");
},
data() {
return {
Expand Down
18 changes: 13 additions & 5 deletions resources/js/components/setting/form/FormGateOut.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
:class="formErrors.shortcut_key ? 'is-error' : ''"
>
<el-input
maxlength="1"
placeholder="Shortcut Key"
v-model="formModel.shortcut_key"
></el-input>
Expand All @@ -37,10 +36,19 @@
label="Jenis Kendaraan"
:class="formErrors.jenis_kendaraan ? 'is-error' : ''"
>
<el-input
placeholder="Jenis Kendaraan"
<el-select
v-model="formModel.jenis_kendaraan"
></el-input>
placeholder="Jenis Kendaraan"
style="width: 100%"
multiple
>
<el-option
v-for="k in jenisKendaraanList"
:value="k.nama"
:label="k.nama"
:key="k.id"
></el-option>
</el-select>
<div class="el-form-item__error" v-if="formErrors.jenis_kendaraan">
{{ formErrors.jenis_kendaraan[0] }}
</div>
Expand Down Expand Up @@ -175,7 +183,7 @@ export default {
formModel() {
return this.model;
},
...mapState(["kameraList", "posList"]),
...mapState(["kameraList", "posList", "jenisKendaraanList"]),
},
data() {
return {
Expand Down
Loading

0 comments on commit 9eb59ce

Please sign in to comment.