added booking table to admin home

integrate booking list to admin home
This commit is contained in:
Jack Goh
2018-06-21 17:35:08 +08:00
parent b5d8fd4e72
commit b9c0bc53fd
2 changed files with 38 additions and 3 deletions
+10 -2
View File
@@ -18,9 +18,17 @@ class BookingController extends Controller
{
public function index(){
$user = Auth::user();
if ($user->roles->first()->name == 'admin'){
$bookings = Booking::select('id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
->get();
}
else{
$bookings = Booking::select('id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
->where('user_id',Auth::user()->id)
->get();
->where('user_id', $user->id)
->get();
}
// reformat to fit frontend structure
foreach ($bookings as $booking) {
+28 -1
View File
@@ -45,6 +45,8 @@
</template>
<script>
import axios from 'axios'
export default {
middleware: 'admin',
data () {
@@ -52,7 +54,32 @@ export default {
bookingTable: [
]
}
},
mounted(){
axios
.get('/api/booking/')
.then((response) => {
console.log(response)
this.bookingTable = response.data
//loading.close()
}).catch((error) => {
// console.log(error)
// loading.close()
// this.$router.push({
// name: 'notfound'
// })
})
},
methods :{
filterTag(value, row) {
return row.tag === value
},
filterHandler(value, row, column) {
const property = column['property']
return row[property] === value
},
}
}
</script>