how to display the following rows and columns in a foreach? here’s my code public function index() { $users = User::with(‘absen’)->get(); $period = CarbonPeriod::create(‘2020-11-25’,’2020-11-30’…
If statement returning false result using date and strtotime
I’m trying to use an if statement to say “If today is between two dates, do this…” etc. It’s not working, and I’m at a total loss because as far as I can see – it SHOULD work! if (date(‘d/…
How to install PHP 8 on XAMPP
I’m trying to update my PHP version to the brand new PHP 8. I have followed simular steps as this tutorial. But now the following error is shown: Notice: I have used a brand new XAMPP instalation version 7.2.33. I can’t find the solution for my issue. Edit It is saying that I need to look into the…
Allowed Memory Size Fatal Error; Improve Script
I have the following function which returns a formatted table to me showing me the list of browsers that viewed the website. It is retrieved from the MySQL Database and the User Agent (I know not totally reliable but it’s good enough for this at this point in time). However; this function (and another t…
PHP/JavaScript apparently not detecting JSON API as valid
I’m trying to make a simple API with PHP and a way to retrieve data from it in JavaScript but I keep getting the following error: SyntaxError: Unexpected token < in JSON at position 0. The JSON is valid and I’m not sure what is causing the error… I’ve tried setting headers and the d…
Datatables: how to preserve id when sorting through a relation from another table (yajra, laravel)
I’m using datatables from yajra datatables and I have a problem. I have a datatable where I obtain certain columns from other tables, for example the column “customer” is obtained through a relation from another table But when I press the sort by customer button, the IDs change to the ID of …
PHPUnit always output “No tests executed!” on MacOS Big Sur
When trying to run any PHPUnit tests, I always get a No tests executed! message on my MacOS machine. A simple way to reproduce, on this specific machine, is to install a fresh instance of Laravel and running the default tests : The expected output would be OK (2 tests, 2 assertions). As far as I know, this is…
Trying to use string as foreign key in laravel
I am just a beginner and trying to use string as foreign key in laravel but getting this error while fetching the data:- SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘read’ in ‘where clause’ (SQL: select from as sender_id, count(from) as messages_count from messages where to …
PHP go to another page and getElementById
I have 2 pages HTML page with a form PHP action page for the form Based on this, if everything is successful with the form submission, I want to go back to the first page and open up a modal using …
PHP: Can I store a function in a class object and pass values to it for the function to interpret. Python can do it, but can PHP?
I’m having a hard time figuring out how to implement code similar to the following Python code: class _Mapper(object): # Holds the name of the function to call when we want to predict a value. …