I have a vue files (many of) similar to the example below. I want to be able to use part of it within PHP to make some tests with.
In short I would like to have something like this
$formFields = array('key=>'value' .....) which has been created from the 'fields' object near the bottom, within the data -> fields -> fields area.
I tried a fair bit, but failed
The general logic I had was
$code = file_get_contents('/resources/js/Components/NameOfVueFile.vue');
$fields = 'some sort of regx, which I could not do- got close with (?s)(?<=fields:)(.*?)(?=],)';
$array = 'no idea how to do that part';
<template>
<AsideLayout v-bind="$props" :loading="state.is(AsideState.LOADING)">
<template v-slot:title>{{ data.id ? 'Edit Account Type' : 'Account Type Form'}}</template>
<SensesForm
v-model="accountType"
v-model:fields="fields"
v-model:error="error"
url="/api/v2/account-types"
:id="data.id"
@stateChange="state = $event"
@success='formSuccess'
:aside-index="asideIndex"
></SensesForm>
</AsideLayout>
</template>
<script>
import AsideLayout from '../../Layout/AsideLayout.vue';
import SensesForm from '../Common/SensesForm.vue';
import Aside from '../../../Mixins/Aside';
import eventHub from '../../../Support/EventHub';
import AsideState from "../../../States/AsideState";
export default {
components: {
SensesForm,
AsideLayout,
},
mixins: [Aside],
data() {
return {
state: new AsideState(),
AsideState,
accountType: {
title: null,
code: null,
include_in_totals: false,
payment_reference: null,
},
error: null,
fields: [
{
title: 'Account Type Information',
description: 'Basic information about the account type',
fields: [
{key: 'title', type: 'text'},
{key: 'code', type: 'text'},
{key: 'include_in_totals', type: 'toggle'},
{key: 'payment_reference', type: 'text'},
],
},
],
};
},
methods: {
formSuccess(data) {
eventHub.emit('account-type-updated', data);
this.$asides.pop();
},
},
};
</script>