Jump to content

requinix

Administrators
  • Content Count

    11,119
  • Joined

  • Last visited

  • Days Won

    211

Everything posted by requinix

  1. requinix

    Strange outcomes with $stmt->fetchColumn()

    fetchColumn() returns an array or false. It does not return a number.
  2. Are there other applications writing to the database besides your own? Do you have any control over them?
  3. requinix

    request()->path() incorrect during testing

    Yeah, I got a little confused about when you wanted the scope. It's about the admin routes, not about whether it's doing testing. Having stepped away from the computer for a couple hours, public static function boot(){ parent::boot(); if(!request()->is('admin/*')){ static::addGlobalScope(new IsActiveScope()); } } The model will only be booted once, and it'll probably happen early. Like for the very first request. Which doesn't help with testing - unless you're requesting against the web server, but it doesn't sound like it. The admin/* check would have to be inside IsActiveScope when it's being applied. So basically what I said before, except instead of the middleware and flag (which I still recommend) you're testing the request() path.
  4. requinix

    request()->path() incorrect during testing

    I believe the most Laravel-y answer is to use your .env settings. Have some value set that your scope can read.
  5. You would have to set up handling for all possible headers that may come back from the Access-Control-Request-Headers. Which is silly. Which is why nobody does that. Their API uses an Authorization (apparently Authorization: Bearer) and an X-API-Key. Just do that. If they change the API then you can change your code.
  6. requinix

    request()->path() incorrect during testing

    I think it will. While I'm not sure why detecting admin/* isn't working, that process uses the request URI while mine uses the router. They're different mechanisms, and as long as the test goes through the router (which I can't imagine it would not) then the router should apply the middleware appropriately. Although one point worth mentioning is that the middleware should undo itself after the request, so IsActiveScope::setEnabled(false); try { return $next($request); } finally { IsActiveScope::setEnabled(); } Routing is one of the first things that happens. It's before the controller. Which should therefore be before most models (except maybe your user) are running queries. The scope is always added to the list of global scopes. What varies is whether the scope actually affects the query - like adding its ->where or whatever just before the query is executed - and that's what is controlled by $enabled.
  7. requinix

    request()->path() incorrect during testing

    Managing the scope in your model based on request feels weird. I would have put the admin routes inside a group with middleware like Route::group(["prefix" => "/admin", "middleware" => "with-inactive-models"], function() { Models needing it add the scope, and with-inactive-models can disable it globally - at the simplest, class IsActiveScope { private static $enabled = true; public static function setEnabled($enabled = true) { self::$enabled = $enabled; } } And IsActiveScope checks $enabled before applying itself.
  8. requinix

    How to access symmetric key?

    With PHP? No. SSL stuff is all handled by OpenSSL (or whatever you have installed) which tends not to expose information like that. You could allow unsecure connections when a development mode is active, and/or when the connection is local. To troubleshoot locally.
  9. requinix

    Issue with PHP

    a) Use AJAX to fetch the HTML b) Use AJAX to fetch the options as JSON and add them to the <select> with Javascript
  10. requinix

    Help with a foreach loop issue from json source

    So you already have a foreach on the dates, suggesting you understand the foreach and the dates. Sounds like what you want is a secondary foreach on the $arr[games]...
  11. requinix

    Help with a foreach loop issue from json source

    That Pastebin is private.
  12. requinix

    Returning before complete

    Sounds like you picked a good point in the process. Not... really? A Promise is a design pattern for dealing with asynchronous operations. XMLHttpRequest doesn't do that - it's just pure functionality. If I could I would have the socket server (the place you chose) try to determine whether the operation will be long-running or not. Would be nice. Anyways, the server should use one response if the request was completed (eg, 200) and another distinctly different response if it was accepted but is not yet completed (eg, 201). The client recognizes each for what it is and, perhaps, passes that information upstream back to the HTTP portion. Whether the client can then "saveInDB", I don't know, I would imagine that depends on whether "accepted but not yet completed" counts as success. Perhaps not.
  13. Stop what you're doing and upgrade. It's a bug, but you're running software from five years ago.
  14. Single quotes are for strings. The name of your database is not a string. For the file not found error it sounds like either MySQL is not running (seems to be running) or its configuration does not match what your PHP setup is expecting regarding how to connect - a socket. As a test change the host to 127.0.0.1. If it works then change it back and figure out the socket problem.
  15. requinix

    I am new here. And I have a question.

    We'd appreciate you not using this forum to advertise your project, but you're free to put a link in your signature and help out on the forums by participating and helping answer questions.
  16. requinix

    Trouble dumping the Request Cookies from a URL

    The cookies come from response headers, so use some mechanism to get the response headers (eg, cURL) and extract the cookies from the Set-Cookie headers.
  17. requinix

    Newbie Question!

    Really hard to know without having access to all the code... Have you see their forums, or I guess joined their Slack group? The problem with questions about topics like this Formidable stuff is that you can't go around showing anyone (like us) what code you're working with because of copyrights, but we kinda need to see that code in order to know what to do. So their own support channels are the best place to start.
  18. requinix

    Turn checkboxes on or off programatically

    I'm not sure why you're asking this: you already know how to make checkboxes marked through the "checked" attribute... If you don't want them to be checked then, you know, don't use the attribute.
  19. requinix

    Read folder

    No, there is more, you just don't understand file systems. is_file
  20. requinix

    Read EXIF Orientation & Rotate Image

    Okay. And?
  21. requinix

    Returning before complete

    Pick a point in the process where you decide that it is potentially long-running. Have the server end return immediate information (eg, HTTP has a 201 Created response), possibly with information that allows the client to poll the server for the final result. Then end the connection and run in the background.
  22. Exactly what does "not working" mean?
  23. requinix

    Need help finding the right query (basic)

    If message_date is a DATE then the string you need should be a YYYY-MM-DD formatted value. However you get that. You haven't shown that part. If message_date is not a DATE, or at least a DATETIME or maybe TIMESTAMP, then you have to fix that first.
  24. requinix

    File permission issues

    Are you sure both users need to be able to write to that directory? Normally it's just one: the PHP user (assuming you're running with php-fpm). The web server should be content with the default 0644 permissions that would let it read.
  25. Depends what mechanism they use to select multiple options. One way or another you end up with an array of IDs. Make sure every single value in there is a valid ID (eg, is a number) then yes, you could use an IN (...) clause instead of your id=. inb4 prepared statements
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.