I was trying to pass a parameter from my database to my view. Controller Route Blade/View And from PHPMyAdmin, we can see a table named statisticforteacher, and each column name is also right. However, I still get the following error. ErrorException Undefined property: IlluminateDatabaseMySqlConnection::$Id Answer Here $data return query builder instance so you have to return collection in order to
Tag: laravel
Laravel Livewire not persisting data in array when updating
I have a property called public $items = []. This can have multiple nested arrays, ie: $items.1, $items.2, $items.3 and so on. Each of these sub arrays needs to hold at least two pieces of data. My issue is that in my view, I have two inputs bound to these sub properties. I then add a new array entry based
Redirect to default locale if not given and fortify routes
I made a middleware to change the language of my website but now I am facing two problems, so I would like your help to solve them: when the user types for instance http://mywebiste/en/operations the site is displayed in English, but if I omit the locale on the URL a 404 page is thrown. My intention is to automatically redirect
Custom service provider for Lumen
I’m new to Lumen, and have a fresh install (v8.2.4) and have followed the docs, trying to write my own service, but I keep getting error Like I said, its a fresh install according to the Lumen docs. in /bootstrap/app.php in /app/Providers/BatmanServiceProvider.php My controller: app/Http/Controllers/MainController.php What am I missing/doing wrong? Answer in /bootstrap/app.php in /app/Providers/BatmanServiceProvider.php create Services folder in your_lumen_project/app,
How to mock Eloquent Model in Laravel 8 when calling a route in PHPUnit
I’m trying to mock a method in the Model so that I am able to test the controller api endpoint with different scenarios. I am currently using Laravel 8 with PhpUnit and Mockery package. In the route I am using Route model binding. api.php ProjectController.php ProjectControllerTest.php I am currently getting this error I have tried other options like makePartial() instead,
Logging into a soap API with cURL and Laravel
I’m having some trouble with this. I am trying to login to a Soap API with SSL I have generated the .pem file and can verify it is good by doing the following The following give me HTTP/1.1 202 Accepted Now, when I essentially try to do the same thing within a laravel controller with the following, I get the
How to load data from cache to a form in a laravel application?
I’m developing a site in laravel. I have a view for editing and creating posts that brings the data stored from the database. For example: The problem is that when the user makes modifications, try to save the data and has validation errors, he loses all the modifications he made (because when laravel reloads the page, the data is again
unable to display session variables in a non-auth application
I’m trying to store and retrieve form data in laravel session. My app is non-auth, meaning users are not required to register, hence no authentication. After attempting to store form data in session, when I try to output it says: “Trying to get property ‘name’ of non-object” Why do I get this? Does laravel session by default work only with
Getting specific column in Laravel relation returning empty array
I want to get specific column from Model relation in Laravel, but the relation model returning empty array. Eloquent Query Medicine Modal Answer You always need to also select the primary and foreign keys of the table to make the relation work:
Only some values are editing with a form Laravel 8
I am using a form and I don’t know why I can edit with it the values except in the fields apellido and cedula. I am using the same logic in all the form fields so I dunno what can be causing it. I’m gonna post the code of the view, controller, and model. View Controller Model I have no