Skip to content

Instantly share code, notes, and snippets.

@elinardo10
Last active July 4, 2019 03:36
Show Gist options
  • Save elinardo10/1106947a4a5d34bf7f83457b905a6e59 to your computer and use it in GitHub Desktop.
Save elinardo10/1106947a4a5d34bf7f83457b905a6e59 to your computer and use it in GitHub Desktop.
<template>
<v-layout row wrap>
<v-flex lg12 xs12 sm12>
<v-card>
<v-card-title>
<v-btn
flat
icon
dark
small
color="primary"
:to="{ name:'quotations' }"
>
<v-icon>chevron_left</v-icon>
</v-btn>
<v-spacer />
<v-subheader>
<span class="headline">Detalhes do Pedido</span>
</v-subheader>
<v-spacer />
</v-card-title>
<v-list
two-line
>
<v-list-tile>
<v-list-tile-action>
<v-icon color="primary">
location_on
</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>{{ titleHotel }}</v-list-tile-title>
<v-list-tile-title>{{ enderecoHotel }}</v-list-tile-title>
<v-list-tile-sub-title>Orlando, FL 79938</v-list-tile-sub-title>
</v-list-tile-content>
</v-list-tile>
<p class="headline">
#Tipo de quarto
</p>
<v-list-tile>
<v-list-tile-action>
<v-icon color="primary">
hotel
</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>{{ room.type }}</v-list-tile-title>
<v-list-tile-sub-title>R$ {{ room.price }}</v-list-tile-sub-title>
</v-list-tile-content>
</v-list-tile>
<v-divider inset />
<p class="headline">
#Dados do Cliente
</p>
<v-list-tile>
<v-list-tile-action>
<v-icon color="primary">
person
</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>
Cliente: {{ user.first_name }} {{ user.last_name }}
</v-list-tile-title>
<v-list-tile-sub-title>
<v-icon>mail</v-icon> {{ user.email }}
</v-list-tile-sub-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-card>
</v-flex>
</v-layout>
</template>
<script>
import { mapMutations } from 'vuex';
export default {
middleware: 'auth',
name: 'QuotationId',
data() {
return {
id: this.$route.params.id,
hotel: {},
user: {},
metas: [],
room: {},
errors: {},
loading: false,
};
},
computed: {
enderecoHotel() {
// Js é muito lindo s2
return this.metas.map(meta => meta.address).toString();
},
titleHotel() {
return this.metas.map(meta => meta.title).toString();
},
},
created() {
this.fetchQuotation(this.id);
},
methods: {
fetchQuotation(id) {
this.$axios.get(`quotations/${id}`, this.hotel).then((response) => {
this.hotel = response.data.data.hotel;
this.room = response.data.data.room;
this.user = response.data.user;
this.metas = this.hotel.metas.map(item => item);
console.log(this.hotel);
console.log(this.user);
console.log(this.metas);
console.log(this.room);
})
.catch((error) => {
this.errors = error.response.data.errors;
});
},
...mapMutations({
setSnack: 'snackbar/setSnack'
})
}
};
</script>
<?php
namespace App\Acme\Models;
use Illuminate\Database\Eloquent\Model;
class Quotation extends Model
{
protected $fillable = ['data', 'user_id'];
protected $casts = [
'data' => 'array',
];
public function user()
{
return $this->belongsTo(User::class);
}
}
@tiagomatosweb
Copy link

tiagomatosweb commented Jun 27, 2019

// Salva quotation
$$user = User::updateOrCreate(
[
'email' => $input['email'],
],
[
'first_name' => $input['first_name'],
'last_name' => $input['last_name'],
'email' => $input['email'],
...
]
);

$quotation = [
'data' => json_encode([
'hotel' => [...],
'room' => [...],
'language' => [...],
]),
user_id => $user->id
'first_name' => $input['first_name'],
'last_name' => $input['last_name'],
'email' => $input['email'],
...
];

$quotation = Quotation::create($quotation);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment