jswoolf01's avatar

jswoolf01 wrote a reply+100 XP

2d ago

Well, I didn't change the htdocs location - it's still c:/xampp/htdocs, so I'm not sure how that would make a difference. I looked through all the other config files I know about and couldn't find anything that looked wrong, but that may just mean there's a config file I don't know about.

I did manage to fix one of the 'path not found' calls by removing a leading slash from the route in web.php. However, the same fix didn't work with another call that has been generating the 'path not found' error.

jswoolf01's avatar

jswoolf01 wrote a reply+100 XP

4d ago

The routes I'm trying to use are in the routes list. If I run the php artisan server, the route redirects work properly and I do not get the error.

jswoolf01's avatar

jswoolf01 wrote a reply+100 XP

4d ago

Sorry to report that didn't help, Glukinho. I even threw in a clearing of browser cache, to make sure nothing was lingering there. No joy.

jswoolf01's avatar

jswoolf01 started a new conversation+100 XP

5d ago

Situation: I have a Laravel app with a production version, a staging version, and the development version that I keep on my local hard drive. My dev computer uses XAMPP as its server. Up until a month or so ago, the dev version was in a folder directly under C:, not under xampp/htdocs. I had created a virtual host to redirect "app.test" to the app's root folder, and it all worked fine that way.

Then I reorganized my hard drive, and in the process I moved the dev version to a folder of its own under xampp/htdocs. At the time this didn't seem to make any difference, and it still ran fine. However, while experimenting with a new function today, I discovered that certain routes no longer work. To be exact, any route that gets referenced through an ajax GET call returns a 404 error, even though the route absolutely does exist in web.php, and the code in the web.php file hasn't changed. This problem is limited to my dev version; the routes still work correctly in the staging and production versions. This convinces me that it's a configuration error.

I've checked and confirmed that references to the old virtual host are commented out in the vhosts file. URL rewriting is definitely enabled. The URLs I'm trying to call show up in the routes list. I've shut down and restarted the Xampp server, and even completely rebooted the computer in case something was lingering in RAM. I've checked route definitions, cleared the route cache, checked the syntax of the URLs being called, checked httpd.conf and .htaccess, regenerated the autoload files... everything I can think of. Nothing has helped.

What else could be causing this?

jswoolf01's avatar

jswoolf01 wrote a reply+100 XP

2w ago

Because I've had it happen in the past that I tried something myself, thought I had it right, then later discovered there was some aspect of it that I didn't know about, which resulted in my code working as intended sometimes and not working sometimes, and figuring out exactly what was going on and how to fix it was hellish. Worse, on at least one occasion I discovered that there was no way to fix it; I had to throw out several days worth of work and start over from scratch.

jswoolf01's avatar

jswoolf01 started a new conversation+100 XP

2w ago

I'm writing some complex validations for an inventory table - a table of products. This Products table has a couple of related child tables. I'd like to save some resources by only running validations for fields that have changed.

Scenario: I edit Product A, change a couple of fields in the Product record and also change some of the data that's stored in one of the child tables. Next, I edit Product B and only change child-table data; the Product record isn't changed at all.

What will wasChanged() show for Product A? What about for Product B?

jswoolf01's avatar

jswoolf01 wrote a reply+100 XP

1mo ago

A thorough and easy-to-understand answer, jsanwo64. Thanks. I had a feeling it was a precedence issue, but didn't know how to fix it. .

jswoolf01's avatar

jswoolf01 started a new conversation+100 XP

1mo ago

Situation: I have three tables: Product (inventory products), Flags (indicator flags that show 'something needs attention'), and Rules (rules for creating Flags). The relationship chain goes product->flags->rules. Each product can have many flags, while each flag belongs to one rule (but one rule can have many flags).
We're transitioning to a new way of defining and handling flags. Under the old way, the flag record itself contains a flag message, and the first few characters of the message are the severity. Under the new way, the severity is shown by a boolean field in the rule definition: false means low severity, true means high severity.
I need a way to retrieve all flags for a given product where severity = 'high', whether the flag was defined under the old way or the new way. That is, I want a query in a Product class method that says "retrieve all flags for this product where either flag->message like 'HIGH%' or flag->rule->severe = TRUE."
I've tried the straightforward approach:

$flagList = $this->flags()
			->where('message',  'like', 'HIGH%')
			->orWhere('rule->severe',TRUE) 
			->get();

but got an error because table Flags doesn't contain a column called 'rule'. I also tried using an orWhereHas query:

$flagList = $this->flags()
			->where('message', 'like', 'HIGH%')
			->orWhereHas('rule',function($q) {
					$q->where('severe',TRUE);
				})
			->get();

but that didn't work either -- I got all high-severity flags on all products, not just the current one. How do I do this query?

Thanks.

jswoolf01's avatar

jswoolf01 wrote a reply+100 XP

3mos ago

If App 1 is running on Apache and App 2 is running on "php artisan serve", I don't get the error. It's clumsy to set up, but it looks like I can use that as a workaround. Thanks for the idea.

Gotta admit, though, I don't understand that at all. How can the php artisan server even see a database created in XAMPP's MySQL instance??

jswoolf01's avatar

jswoolf01 wrote a reply+100 XP

3mos ago

Let me see...

Config shows significant differences between app 1 and app 2: app 1 has connections to sqlite, mysql, mysql_old, pgsql, and sqlsrv. App 1 also has a redis entry for "cache" as well as the default one. App 2 has database connections for sqlite, mysql, and pgsql, and only a default redis connection. The database names used in both are correct.

There are a few raw queries in app 2, but none in the specific sequence that fires when the API call from App 1 comes in. App 2 doesn't mention app 1's database by name anywhere.

Is this something to do with the redis cache, perhaps?

jswoolf01's avatar

jswoolf01 wrote a reply+100 XP

3mos ago

Update: I figured out what I did wrong to get the blank screen and have fixed it. I still am getting the original error, in which App 2 tries to use App 1's database instead of its own.

jswoolf01's avatar

jswoolf01 wrote a reply+100 XP

3mos ago

There is no DB_NAME defined in either app's .env file. There is a DB_DATABASE, and each env file has the correct database name there.

I noticed that one env file had the DB_HOST as 127.0.0.1 and the other had it as "localhost". I set both to be "localhost" and now the new function in App 1 won't run at all. Won't even acknowledge changes in its own code. No matter what I do, as soon as I try to call this new function, I get a blank screen. The rest of App 1 seems to work fine, but the new bit might as well not be there. I just changed the route:: call to call a function that doesn't exist, cleared browser cache, cleared Laravel cache, and tried calling it -- and still got just a blank screen. No error message of any kind, nothing in the console, just a blank screen.

jswoolf01's avatar

jswoolf01 started a new conversation+100 XP

3mos ago

I have two Laravel apps that I'm trying to get to work together on a local XAMPP server. Specifically, I'm testing a reporting feature on application 1 (a retail-sales-tracking app) that requests some data from application 2 (an inventory-tracking app). In production the two run on different servers, but this is my local test machine so they're both running on the same server, and both databases are accessible from the same MySQL session.

I've written an API request handler in app 2 that can successfully handle the data request when I send it from Postman. However, when I try to call that API path from app 1, it fails because of a "table not found" error. Specifically, the error message in the log says "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'app1.settings' doesn't exist". There is no table called "settings" in App 1 -- but there is one in App 2, and the error is being thrown from App 2.

It looks like something somewhere is not getting reset to recognize the change from App 1 to App 2, so App 2 doesn't know to use "App2" as the database name instead of "App1". Is this correct? If so, how can I explicitly force App 2 to look at its own database in this situation?