Skip to main content

Frequently asked questions

How to make testing my application easier?

You can enable auto-filling of your fields via the qore/testing module.

See https://qore.qlic.nl/docs/1.0/developer-notes#useful-development-tools for more.

How to manage countries?

You can activate, deactive and set a country as "the default" country on the resources/countries page.

How to do something when a module or plugin is activated?

When a module is being activated or deactivated, an action (Actions and hooks) is fired:

run('enable.extension', $extension);
run('disable.extension', $extension);

So for example, when you would like to do something after an extension has been activated, create a Hook class:

actions()->after('enable.extension', MyCustomHook::class);

If you dd($this) in your custom hook, you will find the necessary arguments.

Can I customise the resource log dialog?

Yes, you should create a custom Vue component:

import Test from 'components/Test'

Vue.component('ResourceLogsDetailsDialog', Test)

Which should look something like:


<template>
<base-dialog
v-model="shown"
v-on="$listeners"
v-if="row"
:title="row.description"
:minWidth="$q.screen.gt.md ? 600 : 400"
:content="$t('No details found')"
>
<!-- CHANGES -->
<changes
v-if="row.details.changes.length > 0"
:row="row"
:fields="fields"
/>

<!-- SESSION -->
<session
v-if="row.details.session"
:row="row"
:fields="fields"
/>
</base-dialog>
</template>

<script>
import Changes from 'qore/components/elements/tabs/log/details/Changes'
import Session from 'qore/components/elements/tabs/log/details/Session'

export default {
props: ['resource', 'model', 'row', 'dialog', 'fields'],
components: {
Changes,
Session
},
watch: {
row: {
deep: true,
handler(val) {
if (val) {
this.shown = true
}
}
}
},
data() {
return {
shown: this.dialog
}
}
}
</script>

How to improve performance?

There could be a few reasons why a specific resource page could be slow.

If your Index page is slow, have you tried:

  • Overriding the indexQuery method on your resource, and appending ->with() for all relationships?
  • Is there a field that does something intensive in the displayUsing callback?

If the customer demands your table to have 100 or more results per page, Vue may slow down your load because each field has its own Index component which needs to be renedered. This isn't really a problem for Text fields, but can be slowed down if you have many BelongsTo or DateTime fields for example. In this specific case, you should maybe override the index component and render the table yourself.


If something else is slow, you could always check telescope in your browser, or install something like Laravel clockworks.

How do I get a list of all resource fields?

Sometimes you need to loop over all fields that exists in a resource, you can do this:

// All fields
run('get.resource.fields', ['resource' => $this])

// For a specific method
run('get.resource.fields', ['resource' => $this, 'method' => 'create'])
run('get.resource.fields', ['resource' => $this, 'method' => 'edit', 'model' => $model])
run('get.resource.fields', ['resource' => $this, 'method' => 'index'])
run('get.resource.fields', ['resource' => $this, 'method' => 'show', 'model' => $model])
run('get.resource.fields', ['resource' => $this, 'method' => 'export'])

Why is my URL so long inside a form?

Field metadata

When you detect a long url (or even an error on a staging/live environment because of this), it is probably caused by exposing too much field metadata in your form.

When you set field metadata (via ->setFieldMeta) it means this metadata will be sent back as a response, but also sent to the back-end in each request (causing your url to be long).

When you don't care about this metadata on the back-end, you should use ->setFieldData instead. This is only sent in the response.

See also Different kinds of data for more information.

Field state value

The reason for a long URL can also simply be because the value of your field (the state) contains a lot of information. The state will always be sent back and forth, but you can disable this with public bool $transfersState = false; on your field.

See also Transfer state for more information.

Why is my custom field not working / being rendered in tables?

Assuming you have registered your components in the front-end, it could be because your Field is extending another field (like Select) which only allows text displays in tables for performance reasons.

You can fix this by editing the following on your Field:

/**
* @var bool
*/
public bool $rendersTextOnIndex = false;

See also Creating a field for more information.