add new role for jawatankuasa audit
This commit is contained in:
@@ -31,7 +31,8 @@ class AddController extends Controller
|
|||||||
'name' => 'required|unique:users',
|
'name' => 'required|unique:users',
|
||||||
'email' => 'required|email|unique:users',
|
'email' => 'required|email|unique:users',
|
||||||
'password' => 'required',
|
'password' => 'required',
|
||||||
'confirm_password' => 'same:password'
|
'confirm_password' => 'same:password',
|
||||||
|
'role' => 'required'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ class User extends Authenticatable
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name', 'email', 'password',
|
'name', 'email', 'password', 'role'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddRoleToUsersTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->string('role', 60);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->dropColumn('role');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,62 +1,71 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form id="add_form" @submit.prevent="add()">
|
<form id="add_form" @submit.prevent="add()">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Nama</label>
|
<label for="name">Nama</label>
|
||||||
<input type="text" name="name" class="form-control" required/>
|
<input type="text" name="name" class="form-control" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email">Email</label>
|
<label for="email">Email</label>
|
||||||
<input type="email" name="email" class="form-control" required/>
|
<input type="email" name="email" class="form-control" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">Password</label>
|
<label for="password">Password</label>
|
||||||
<input type="password" name="password" class="form-control" required/>
|
<input type="password" name="password" class="form-control" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="confirm_password">Confirm Password</label>
|
<label for="confirm_password">Confirm Password</label>
|
||||||
<input type="password" name="confirm_password" class="form-control" required/>
|
<input type="password" name="confirm_password" class="form-control" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="submit" value="Submit" class="btn btn-info"/>
|
<label for="role">Role</label>
|
||||||
<router-link :to="{name: 'Manage Account'}" class="btn btn-default">Back</router-link>
|
<select class="form-control" id="role" name="role"
|
||||||
</div>
|
value="" required>
|
||||||
|
<option value="1">Admin</option>
|
||||||
|
<option value="2">Jawatankuasa Audit</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
<div class="form-group">
|
||||||
|
<input type="submit" value="Submit" class="btn btn-info" />
|
||||||
|
<router-link :to="{ name: 'Manage Account' }" class="btn btn-default">Back</router-link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default{
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
loading: false
|
loading: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
methods:{
|
methods: {
|
||||||
add: function () {
|
add: function () {
|
||||||
if (this.loading || !this.isPasswordMatch()) return;
|
if (this.loading || !this.isPasswordMatch()) return;
|
||||||
var vm = this;
|
var vm = this;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.util.notify('Adding Admin', 'loading');
|
this.util.notify('Adding Admin', 'loading');
|
||||||
axios.post(config.API+'admin', $('#add_form').serialize())
|
axios.post(config.API + 'admin', $('#add_form').serialize())
|
||||||
.then(response=>{
|
.then(response => {
|
||||||
vm.loading = false;
|
vm.loading = false;
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
if (vm.util.showResult(response, 'success')) {
|
if (vm.util.showResult(response, 'success')) {
|
||||||
vm.$router.push({name: 'Manage Account'});
|
vm.$router.push({ name: 'Manage Account' });
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error=>{
|
.catch(error => {
|
||||||
vm.loading = false;
|
vm.loading = false;
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
vm.util.showResult(error, 'error')
|
vm.util.showResult(error, 'error')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -65,6 +74,6 @@ export default{
|
|||||||
if (!isMatch) this.util.notify('Password not match', 'error');
|
if (!isMatch) this.util.notify('Password not match', 'error');
|
||||||
return isMatch;
|
return isMatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -14,22 +14,21 @@
|
|||||||
<div class="collapse navbar-collapse" id="myNavbar">
|
<div class="collapse navbar-collapse" id="myNavbar">
|
||||||
|
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
|
<!-- {{ users }} -->
|
||||||
<router-link :to="{name: 'Admin Home'}" tag="li" exact><a href="#">Home</a></router-link>
|
<router-link :to="{name: 'Admin Home'}" tag="li" exact><a href="#">Home</a></router-link>
|
||||||
|
<router-link :to="{name: 'Kemaskini Jawatan'}" v-if="data.user.role==1" tag="li">
|
||||||
<router-link :to="{name: 'Kemaskini Jawatan'}" tag="li">
|
|
||||||
<a href="#">Jawatan</a>
|
<a href="#">Jawatan</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link :to="{name: 'Manage Partylist'}" tag="li">
|
<router-link :to="{name: 'Manage Partylist'}" v-if="data.user.role==1" tag="li">
|
||||||
<a href="#">Manage Partylist</a>
|
<a href="#">Manage Partylist</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link :to="{name: 'Manage Voter'}" tag="li">
|
<router-link :to="{name: 'Manage Voter'}" v-if="data.user.role==1" tag="li">
|
||||||
<a href="#">Anggota Koperasi</a>
|
<a href="#">Anggota Koperasi</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link :to="{name: 'Maklumat Calon'}" tag="li">
|
<router-link :to="{name: 'Maklumat Calon'}" v-if="data.user.role==1" tag="li">
|
||||||
<a href="#">Calon</a>
|
<a href="#">Calon</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
@@ -75,9 +74,10 @@
|
|||||||
<script>
|
<script>
|
||||||
export default{
|
export default{
|
||||||
|
|
||||||
data: () =>({
|
// data: () =>({
|
||||||
loading: true
|
// loading: true,
|
||||||
}),
|
// users:{'roles' : 1},
|
||||||
|
// }),
|
||||||
|
|
||||||
created: function () {
|
created: function () {
|
||||||
this.util.setTitle('Voting System - Administrator');
|
this.util.setTitle('Voting System - Administrator');
|
||||||
|
|||||||
Reference in New Issue
Block a user