adrema/resources/js/mixins/hasFlash.js

32 lines
847 B
JavaScript
Raw Normal View History

2023-03-04 12:02:17 +01:00
export default {
methods: {
['$success'](message) {
this.$toasted.show(message, {
position: 'bottom-right',
duration: 2000,
type: 'success',
});
},
['$error'](message) {
this.$toasted.show(message, {
position: 'bottom-right',
duration: 2000,
type: 'error',
});
},
2023-03-04 15:23:45 +01:00
errorsFromException(e) {
if (e.response?.status !== 422 || !e.response?.data?.errors) {
throw e;
}
var errors = e.response.data.errors;
Object.keys(errors).forEach((field) => {
errors[field].forEach((message) => {
this.$error(message);
});
});
},
2023-03-04 12:02:17 +01:00
},
};