TypeError: Cannot read properties of null (reading 'name') In cpanel hosting
I am facing an unwanted and odd problem in my project. It's showing in one of my module's main index pages, displaying the following error.
TypeError: Cannot read properties of null (reading 'name').
In CPanel hosting
I have already checked the casing (OK). I tried to create another module (similar problem). Have a laravel through relationship in parent model(company). It's fine on my local machine and creates; edit route works fine in the live server (also, I have similar crud, which works fine)
Controller
public function index(Request $request)
{
return Inertia::render('Pesticides/Index', [
'pesticides' => Pesticide::with('company')
->filter($request->all())
->sorted()
->paginate()
->withQueryString(),
'query' => $request->all(),
]);
}
Model
class Pesticide extends Model
{
public function units()
{
return $this->belongsTo(Unit::class);
}
public function company()
{
return $this->belongsTo(Company::class);
}
public function pesticideSale()
{
return $this->hasMany(PesticideSale::class);
}
}
Please help.
I appreciate any help you can provide.
do you know?
how many words do you know
See also questions close to this topic
-
how to change prettier format for react native
my code formatting prettier didn't works well for react native, i don't understand where to config it but it works well with flutter
from this code
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( <View> <Text>Apps</Text> </View> ) }
it's formatted to this
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( < View > < Text > Apps < /Text> < /View> ) }
-
MarkLogic server-side JavaScript and XQuery
I am just starting using NoSQL MarkLogic DB and trying to choose for me the best query language to learn and use in future. On server side MarkLogic provides the possibility to use JavaScript API or XQuery API.
I want to receive an advice. Which language is better to concentrate on and learn? JavaScript or XQuery?
- Popover in chrome extension using js
-
delete a table form a database using laravel command
i need to delete a database table using laravel artisan command . not like this command php artisan migrate:rollback --step=5
i need to create like this route or controller code .
Route::get('/clear/database', function () {
Artisan::call('cache:clear'); return redirect('/');
});
. i also try public function dd()
{ Schema::drop('table_name'); }
but it not working . gives me error like this SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (SQL: drop table
table_name
)no foreign key for the table . what should i do ?
thanks in advance!
-
Foreach for Categories
i have this data, I want to loop with categories for each question. Right now all I can do is loop by displaying sequentially for each question (as in the image).what I want to do is loop and group them based on categories_id , if the categories_id changes it will be given a new line.
// 20220507095412 // http://127.0.0.1:8000/user/exams [ { "id": 16, "ujians_id": 11, "questions_id": 3, "mulai": null, "berakhir": null, "durasi": 60, "isAnswer": 0, "created_at": "2022-05-07T02:53:56.000000Z", "updated_at": "2022-05-07T02:53:56.000000Z", "questions": { "id": 3, "title": "2", "question": "<p>Sarana yang sangat masih dalam menyebabkan oposisi dunia yang sering berdampak pada intervensi asing terhadap Indonesia pada era globalisasi sekarang ini adalah...</p>", "img": null, "categories_id": 1, "created_at": "2022-05-07T02:11:41.000000Z", "updated_at": "2022-05-07T02:11:41.000000Z" } }, { "id": 17, "ujians_id": 11, "questions_id": 1, "mulai": null, "berakhir": null, "durasi": 60, "isAnswer": 0, "created_at": "2022-05-07T02:53:56.000000Z", "updated_at": "2022-05-07T02:53:56.000000Z", "questions": { "id": 1, "title": "13", "question": "<p>Wahidin soedirohoesodo memilik peran penting dalam pergerakan kemerdekaan. Antara lain…22234232</p>", "img": null, "categories_id": 1, "created_at": "2022-05-02T10:39:13.000000Z", "updated_at": "2022-05-03T13:28:24.000000Z" } } ]
@php $no=1 @endphp @foreach($dataUjian as $row) @if($row->isAnswer == 0) <button class="btn btn-primary btn-sm" onclick="getUjian({{$row->questions_id}}, {{$row->id}},{{$row->ujians->users_id}})" >{{$no++}}</button> @else <button class="btn btn-danger btn-sm" disabled>{{$no++}}</button> @endif @endforeach
-
Unit testing with get request
I am trying to create a unit test for one of my api.
In the frontend, I send it this way...
params = { participants: JSON.stringify(participants), section: JSON.stringify(section), }; axios.get('/api/list', params)
while in the controller, it receives the params this way...
public function list(Request $request) { $participants = json_decode($request->participants); $section = json_decode($request->section); }
Now, I tried making a unit test out of this. by doing...
$params = [ 'participants' => ['id', 'name', 'rating'], 'section' => ['id', 'code'], ]; $this->get('/api/list'.http_build_query($params))->assertStatus(200) // $this->json('/api/list', $params)->assertStatus(200) // -> also tried this one // $this->getJson('/api/list', $params)->assertStatus(200) // -> also tried this one // $this->call('GET', '/api/list', $params)->assertStatus(200) // -> also tried this one
But none of them works, it always says
TypeError: json_decode(): Argument #1 ($json) must be of type string, array given
.So, the way I built the url and the params must be all wrong,
so my question here is that, what's the correct way of building the url so that it provides a correct url string format and the controller will json_decode the params?
-
How can I get toast-ui editor content?
I am a student studying. I think I'm doing it conceptually wrong.
I'm trying to use vue3 and type script And I'm going to use toast-ui editor.
I get some errors.
- refEditor.value.invoke is not a function
How can I get toast-ui editor content?
this is my code
<template> <div class="markup-tables flex"> <va-card :title="$t('tables.stripedHoverable')"> <va-card-content> <div id="refEditor" ref="refEditor"></div> <br /> <div class="row justify--end paginationButtons-left"> <va-button class="mr-2 mb-2">List</va-button> </div> <div class="row justify--end paginationButtons-right"> <va-button class="mr-2 mb-2" @click="getHTML">Save</va-button> </div> </va-card-content> </va-card> </div> </template> <script lang="ts"> import '@toast-ui/editor/dist/toastui-editor.css' import Editor from '@toast-ui/editor' import { defineComponent, onMounted, ref } from 'vue' import data from '@/data/tables/markup-table/data.json' export default defineComponent({ name: 'BoardWrite', setup() { const refEditor = ref(null) const getHTML = () => { console.log('getHTML test') let html = refEditor.value.invoke('getHtml') console.log(html) // ERROR } onMounted(() => { const editor = new Editor({ el: refEditor.value, height: '700px', initialEditType: 'markdown', previewStyle: 'vertical', }) editor.getMarkdown() }) return { getHTML, refEditor, } }, }) </script>
-
Deploy VueJS + API app to Azure Static Web App with Gitlab doesn't create functions
I've started creating a small application that will use VueJS as a frontend with Azure Functions as the backend. I was looking at using Azure Static Web Apps to host both components for the application and Gitlab to store / deploy the app.
Everything but the creation of the Azure functions works. Following https://docs.microsoft.com/en-us/azure/static-web-apps/gitlab?tabs=vue
The output from the deploy step, listed below is:
App Directory Location: '/builds/*/valhalla/valhalla-client/dist/spa' was found. Api Directory Location: '/builds/*/valhalla/valhalla-api/dist' was found. Looking for event info Could not get event info. Proceeding Starting to build app with Oryx Azure Static Web Apps utilizes Oryx to build both static applications and Azure Functions. You can find more details on Oryx here: https://github.com/microsoft/Oryx ---Oryx build logs--- Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx You can report issues at https://github.com/Microsoft/Oryx/issues Oryx Version: 0.2.20220131.3, Commit: ec344c058843461525ff03b46031553b6e15a47a, ReleaseTagName: 20220131.3 Build Operation ID: |qAffRWArEg8=.deee9498_ Repository Commit : 7cdd5b61f956e6cb8459b13a42af363c4440a97b Detecting platforms... Could not detect any platform in the source directory. Error: Could not detect the language from repo. ---End of Oryx build logs--- Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support. Finished building app with Oryx Starting to build function app with Oryx ---Oryx build logs--- Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx You can report issues at https://github.com/Microsoft/Oryx/issues Oryx Version: 0.2.20220131.3, Commit: ec344c058843461525ff03b46031553b6e15a47a, ReleaseTagName: 20220131.3 Build Operation ID: |NGXLP5bVBRk=.705477f6_ Repository Commit : 7cdd5b61f956e6cb8459b13a42af363c4440a97b Detecting platforms... Could not detect any platform in the source directory. Error: Could not detect the language from repo. ---End of Oryx build logs--- Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support. [WARNING] The function language could not be detected. The language will be defaulted to node. Function Runtime Information. OS: linux, Functions Runtime: ~3, node version: 12 Finished building function app with Oryx Zipping Api Artifacts Done Zipping Api Artifacts Zipping App Artifacts Done Zipping App Artifacts Uploading build artifacts. Finished Upload. Polling on deployment. Status: InProgress. Time: 0.1762737(s) Status: InProgress. Time: 15.3950401(s) Status: Succeeded. Time: 30.5043965(s) Deployment Complete :) Visit your site at: https://polite-pebble-0dc00000f.1.azurestaticapps.net Thanks for using Azure Static Web Apps! Exiting Cleaning up project directory and file based variables 00:00 Job succeeded
The deploy step appears to have succeeded, and the frontend is deployed, but there are no Azure Functions showing up in this Static Web App. Is something missed here? So far, the Azure Functions I have are the boiler-plate from instantiating a new Azure Function folder.
image: node:latest variables: API_TOKEN: $DEPLOYMENT_TOKEN APP_PATH: '$CI_PROJECT_DIR/valhalla-client/dist/spa' API_PATH: '$CI_PROJECT_DIR/valhalla-api/dist' stages: - install_api - build_api - install_client - build_client - deploy install_api: stage: install_api script: - cd valhalla-api - npm ci artifacts: paths: - valhalla-api/node_modules/ cache: key: node paths: - valhalla-api/node_modules/ only: - master install_client: stage: install_client script: - cd valhalla-client - npm ci artifacts: paths: - valhalla-client/node_modules/ cache: key: node paths: - valhalla-client/node_modules/ only: - master build_api: stage: build_api dependencies: - install_api script: - cd valhalla-api - npm install -g azure-functions-core-tools@3 --unsafe-perm true - npm run build artifacts: paths: - valhalla-api/dist cache: key: build_api paths: - valhalla-api/dist only: - master needs: - job: install_api artifacts: true optional: true build_client: stage: build_client dependencies: - install_client script: - cd valhalla-client - npm i -g @quasar/cli - quasar build artifacts: paths: - valhalla-client/dist/spa cache: key: build_client paths: - valhalla-client/dist/spa only: - master needs: - job: install_client artifacts: true optional: true deploy: stage: deploy dependencies: - build_api - build_client image: registry.gitlab.com/static-web-apps/azure-static-web-apps-deploy script: - echo "App deployed successfully." only: - master
-
How to global import a stylus file in vite
Now I'm try use
vite
to create avue
app. But have trouble to global import astylus
file invite.config.js
.I try the code from vite docs.
export default defineConfig({ css: { preprocessorOptions: { styl: { additionalData: `@import "./src/assets/styles/common.styl"` } } } })
But it's completely not work.
I got a solution to set global style from github.
export default defineConfig({ css: { preprocessorOptions: { stylus: { globals: { '$highlight-color': 'red' } } } } })
It's works fine, But how to import a styl file globaly? I tried to add 'additionalData' to the workable config. However I got bunch of errors: 'failed to locate file'. It seems like try to import the file in every .vue file, but has trouble to locate the file.
css: { preprocessorOptions: { stylus: { additionalData: `@import "./src/assets/styles/common.styl";`, globals: { '$color-g1': '#F3F4FC', '$color-white': '#FFFFFF', } } } }
Have any idea about this?
-
Am trying to launch in Cpanel, but am getting a Module not found error
enter image description hereI'm new to Cpanel and am trying to launch my python Django project, I think I've set up everything correctly but am getting this error: File "/opt/alt/python38/lib64/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) ModuleNotFoundError: No module named '<my_module_name>' [UID:2291][2142962] Child process with pid: 2149437 was killed by signal: 15, core dump: 0
so I tried rearranging my apps in settings.py, which has led me to believe that the problem maybe due to the fact that, my app are not being identified. I had created my project using python version 3.9.10, but my cpanel can only support version 3.8.6, so I had to downgrade, and I think this maybe the root of all my issues.
Any help offered would be much appreciated, thanks in advance
-
how can i send registration activation link email from my custom domain email (activate@tiguh.com) using php
i am working on a project (PHP) that allows online registration to access the authenticated only services provided. i want to send the activation link to their email from my custom email address (activate@tiguh.com). can please help me guys. language is (PHP)
i have cpanel access mail() is not working i have tried mail() in another cpanel (another subdomain) it works. i asked the host provider why mail() is not working in my domain and he replies me with the below image.
-
Got Error while installing mysqlclient in django project on cPanel
Requirements.txt contains:
asgiref==3.4.1 Django==3.2.9 django-isbn-field==0.5.3 mysql-connector-python mysqlclient phonenumberslite==8.12.42 Pillow==9.0.1 python-decouple==3.6 python-stdnum==1.17 pytz==2021.3 six==1.16.0 sqlparse==0.4.2
Got error:
Error ERROR: Failed building wheel for mysqlclient ERROR: Command errored out with exit status 1: /home/bookbestie/virtualenv/bookbestie/3.8/bin/python3.8_bin -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nk4wll31/mysqlclient_306f3e44780f440a9c0a625d98f95d89/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nk4wll31/mysqlclient_306f3e44780f440a9c0a625d98f95d89/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-frd2zcuu/install-record.txt --single-version-externally-managed --compile --install-headers /home/bookbestie/virtualenv/bookbestie/3.8/include/site/python3.8/mysqlclient Check the logs for full command output. WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available. You should consider upgrading via the '/home/bookbestie/virtualenv/bookbestie/3.8/bin/python3.8_bin -m pip install --upgrade pip' command.
I am time hosting for the first time. I browsed other posted questions but couldn't find a solution.
-
Inertia.js vs Vuex in Laravel + Vue.js projects
Inertia.js is a replacement for Laravel Blades when using Vue.js But do you see it as a problem for using Vuex? Do you think that Inertia in laravel replaces vuex's pupose?
-
api in laravel with inertia js and passport
I have a problem since we need to create an api with passport to give only certain access to certain clients to our api, but it turns out that the app is made with vue and inertiajs we try to use the default test route that is
api/user
and it returns the html render of inertiajs, of course, this generates the token with passport through the oauth/token route, but nevertheless this does not work, some user here has been able to generate an api, already having an app made with inertiaconfig/auth.php 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'passport', 'provider' => 'users', ], ],
-
How to manipulate browser url in Inertia.js?
I've been using an
IntersectionObserver
to update theurl
of mySPA
while the user scrolls down the page like so:const sections = document.querySelectorAll('section') const options = { threshold: 0.5 } const observer = new IntersectionObserver((entries, observer) => { entries.forEach(entry => { if (entry.isIntersecting) { router.push('#' + entry.target.id) } }) }, options) sections.forEach(section => { observer.observe(section) })
but how do I do this in
Inertia.js
since it doesn't have therouter.push
method? I'm usingInertia
with aVue 3
frontend.