Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions app/Http/Controllers/BottleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ public function show($id)
Log::channel('bottle')->info('Bottles shown.', ['user' => Auth::user()]);

// Get a single bottle
$bottle = Bottle::findOrFail($id);

// Return the single bottle as a resource
return new BottleCollection($bottle);
return Bottle::findOrFail($id);
}

/**
Expand Down
13 changes: 3 additions & 10 deletions resources/assets/components/invDatatable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@ export default {
dataClass: 'text-right'
},
{
name: 'name',
sortField: 'name',
},
{
title: 'Year',
name: 'release_date',
sortField: 'release_date',
titleClass: 'text-center',
dataClass: 'text-center',
callback: 'formatDate|YYYY'
name: 'offering_id',
title: 'Offering',
sortField: 'offering_id'
},
{
name: 'location_id',
Expand Down
50 changes: 37 additions & 13 deletions resources/assets/components/newInv.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
<template>
<form style="padding: 20px; padding-bottom: 50px;" v-on:submit.prevent="submitBottle">

<div class="form-group row">
<label class="col-sm-2 col-form-label">Offering ID</label>
<div class="col-sm-10">
<input class="form-control" v-model="bottle.offering_id" placeholder="9876">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Quantity</label>
<div class="col-sm-10">
<input class="form-control" v-model="quantity">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Location ID</label>
<div class="col-sm-10">
<input class="form-control" v-model="bottle.location_id" placeholder="Down by the Farm">
</div>
</div>
<button class="btn btn-primary" type="submit">Create Bottle!</button>
<p>{{ bottle }}</p>
</form>
Expand All @@ -11,35 +28,42 @@
export default {
data() {
return {
quantity : '',
bottle: {
name : '',
origin : '',
offering_id : '',
location_id : '',
amount : 1,
},
}
},
methods: {
submitBottle() {
axios.post('/api/products', this.bottle)
.then(function (response) {
var result = true;
var i;
for (i = 0; i < this.quantity; i++) {
axios.post('/api/bottles', this.bottle)
.catch(function (error) {
result = false;
});
};
if (result) {
swal(
'Good job!',
'Bottle added successfully!',
'Supplier added successfully!',
'success'
).then((result) => {
if(result.value) {
location.reload();
}
})
})
.catch(function (error) {
swal({
});
} else {
swal({
type: 'error',
title: 'Oops...',
text: 'Something went wrong!',
footer: 'Did you fill out all the required fields?'
})
console.log(error);
});
});
}
},
}
}
Expand Down
1 change: 1 addition & 0 deletions resources/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Vue.component('bws-vuetable', require("../components/bwsDatatable.vue"));
Vue.component('offerings-vuetable', require("../components/offDatatable.vue"));
Vue.component('supplier-vuetable', require("../components/supplierDatatable.vue"));
Vue.component('new-bws-form', require("../components/newBWS.vue"));
Vue.component('new-inv-form', require("../components/newInv.vue"));
Vue.component('new-offer-form', require("../components/newOff.vue"));
Vue.component('new-supplier-form', require("../components/newSupplier.vue"));

Expand Down
2 changes: 1 addition & 1 deletion resources/views/pages/bws/create.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@extends('layouts.app')

@section('title')
New Bottle
New Product
@endsection

@section('content')
Expand Down
15 changes: 15 additions & 0 deletions resources/views/pages/inventory/create.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@extends('layouts.app')

@section('title')
New Bottle
@endsection

@section('content')

@include('inc.inventory.sidebar')

<div class="container" style="padding-top: 150px;">
<h1 style="font-family: 'Muli', serif; font-weight: normal;">Add New Bottle</h1>
<new-inv-form></new-inv-form>
</div>
@endsection