Glukinho wrote a reply+100 XP
3d ago
You may more or less understand what's going on inside the function right now. But after a month or half a year you'll be totally lost, for sure.
Glukinho wrote a reply+100 XP
3d ago
I'm getting the error: JSON ERROR: Syntax error
Where is it exactly? In browser window, in browser console, in logs?..
Glukinho wrote a reply+100 XP
4d ago
How does the error look? Is it Laravel error or generic web server error?
Look into Nginx error logs.
Glukinho wrote a reply+100 XP
5d ago
You misunderstand what observer is. It has nothing to do with your task. You should schedule a command every N minutes (whatever frequency you prefer) which:
- takes records ready to be published (in other words, which have
published_atin less than N minutes in future) - publishes them
- applies service function you want to be applied to "scheduled" records.
Model observers are about events system, this is another topic.
Glukinho liked a comment+100 XP
1w ago
If you use version control, such as Git, recovery is easy. Every developer should always use version control, even if they're working alone.
Another easy way is through an IDE. PhpStorm has a local history that shows file deletions, which you can revert. VS Code is a bit worse in this regard, but it's still possible.
Otherwise, you might be able to do it with some recovery tool. Recovering deleted files is less likely on SSDs than HDDs. Your best bet is to google "undelete tool" and try something to recover it. Recovery becomes less and less likely the longer you keep using the device.
Glukinho wrote a reply+100 XP
1w ago
No, recovering your local deleted files is out of Laravel responsibility. You should search in your local system for such things.
If you use version control system (most likely Git) and committed your controller then search there. But I'm afraid that's not the case otherwise you wouldn't ask.
As last chance you can use some data recovery software and most likely you'll find your file as deleted files are not actually erased from disk. I successfully used R-Studio: https://www.r-studio.com/
But I think rewriting the class is the best option for you. It is not so hard to do, you'll polish the logic at the same time. Rewriting actually helps.
Glukinho wrote a reply+100 XP
1w ago
Glukinho wrote a reply+100 XP
1w ago
INSERT INTO change_logs_backup SELECT * FROM change_logs;
It would take forever. For backup I'd rename change_logs to change_logs_backup and create change_logs from scratch. Same result but almost instantly.
Glukinho wrote a reply+100 XP
1w ago
No valid SQL request would crash a database server, you may not worry about that. It is not a matter of table size in any case.
You can dump table structure using SHOW CREATE TABLE tablename or with mysqldump (there is an option for dumping structure only). After that drop a table and recreate with previously dumped structure.
I'm not sure if TRUNCATE does exactly the same as drop/create, but the result would be the same: clean table without rows.
What I wouldn't do is DELETE FROM tablename as it would be very slow and internal counter for auto increment primary key is preserved (so new row id would be something like 167 000 001 which doesn't seem preferable).
Another issue is reclaiming free space used by InnoDB files; the occupied space isn't released automatically especially if you have innodb_file_per_table = off. There are many articles about releasing occupied space; to be short, you have to make full database backup, set innodb_file_per_table = on and restore backup. After that all tables are stored in their own dedicated files and occupy only space really needed for data.
Glukinho liked a comment+100 XP
2w ago
@eskiesirius You shouldn’t be using a single column to hold the balance. You should instead of some form of ledger table, where you write individual increments and decrements as their own rows, and then derive the balance from the sum of those increments and decrements. It’s not “expensive” if you have a proper index in place.
Glukinho wrote a reply+100 XP
2w ago
Give your data structure (tables, columns) and actual code that "says relationship doesn't exist".
Glukinho wrote a reply+100 XP
2w ago
I agree scopes are good.
Glukinho wrote a reply+100 XP
2w ago
Isn't it your situation described? https://laravel.com/docs/8.x/eloquent-relationships#chaining-orwhere-clauses-after-relationships
How about this?
$products = Product::query()
->where('parent_id', '!=', 0)
->whereHas('flags', function ($query) use ($messages) {
$query
->where('is_valid', 1)
->where(function ($query) use ($messages) {
foreach ($messages as $message) {
$query->orWhere('message', 'LIKE', $message);
}
});
})
->get();
Glukinho was awarded Best Answer+1000 XP
2w ago
You see no bootstrap.js and empty app.js because these files are absent/empty in laravel/laravel repository which is cloned to you every time you install new Laravel app.
The reason why these files were changed in the repository are described by the link I provided.
Something tells me it is related to some Axios vulnerabilities recently discovered.
Sorry maybe I don't fully understand the question...
Glukinho was awarded Best Answer+1000 XP
2w ago
I guess it's about @context, @type which Blade engine recognizes as directives.
See here: https://laravel.com/docs/13.x/blade#blade-and-javascript-frameworks
The @ symbol may also be used to escape Blade directives:
So I think you should either use double @ :
"@@context": "https://schema.org",
"@@type": "WebSite",
Or wrap your scripts with @verbatim ... @endverbatim which prevents it's inner content to be processed by Blade engine:
<script type="application/ld+json">
@verbatim
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "xxx",
...
}
@endverbatim
</script>
Glukinho wrote a reply+100 XP
2w ago
I guess it's about @context, @type which Blade engine recognizes as directives.
See here: https://laravel.com/docs/13.x/blade#blade-and-javascript-frameworks
The @ symbol may also be used to escape Blade directives:
So I think you should either use double @ :
"@@context": "https://schema.org",
"@@type": "WebSite",
Or wrap your scripts with @verbatim ... @endverbatim which prevents it's inner content to be processed by Blade engine:
<script type="application/ld+json">
@verbatim
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "xxx",
...
}
@endverbatim
</script>
Glukinho wrote a reply+100 XP
2w ago
You see no bootstrap.js and empty app.js because these files are absent/empty in laravel/laravel repository which is cloned to you every time you install new Laravel app.
The reason why these files were changed in the repository are described by the link I provided.
Something tells me it is related to some Axios vulnerabilities recently discovered.
Sorry maybe I don't fully understand the question...
Glukinho wrote a reply+100 XP
2w ago
Glukinho wrote a reply+100 XP
3w ago
Why you want v4? Filament 5 was released some time ago, and several updates came already.
Glukinho wrote a reply+100 XP
3w ago
SECURITY PROBLEM: insecure server advertised AUTH=PLAIN (errflg=1)
This error strikes from IMAP connection which is used to access a mailbox, not for sending emails. Where this error goes from in your code? I mean specific file and line.
Glukinho wrote a reply+100 XP
3w ago
So the problem is definitely somewhere inside XAMPP settings. Sorry I'm not very familiar with it. Try to revert your latest changes or even reinstall it from scratch. Looking into Apache logs would be useful also.
...Or you may continue using php artisan serve instead of XAMPP web server.
Glukinho wrote a reply+100 XP
3w ago
Do you have the error when serving app with php artisan serve instead of XAMPP?
Use php artisan route:list, do you have all routes there?
Glukinho wrote a reply+100 XP
3w ago
As usual, first of all try php artisan optimize:clear and recreate vendor folder (delete it and run composer install)
Glukinho wrote a reply+100 XP
3w ago
A clumsy and awkward approach of recreating conventional OOP logic in functional style?
Glukinho liked a comment+100 XP
3w ago
@iamyannc Hey. I’ve done a lot of these type of re-factoring and re-platforming projects in the past. The way I’d approach it would be like this:
- Get the application running on a newer version of PHP. So upgrade to 7, fix any usage of deprecated APIs and libraries, and then when possible upgrade to PHP 8 and do the same.
- Once you’ve got the vanilla PHP application running on a modern version of PHP, create a new Laravel application and dump your legacy application’s file in the public directory.
- Rename Laravel’s index.php file to something like laravel-index.php to avoid clashing with your legacy index.php file.
- Tweak your .htaccess or nginx config to just load a file if it exists, or fall back to Laravel’s front controller.
- You should now have a Laravel application, but with no requests actually being routed through it to start off with, and instead requests hitting your legacy application as before.
- Slowly start re-factoring your legacy application to Laravel controllers, views, etc. Do this slowly, and one discreet part at a time. Trying to re-factor too much in one go just leads to lots of files being touched, none of them 100% converted, and the dreaded feeling of, “Urgh, I need to
git resetthis and start over.” - As you do the above, the number of files from the legacy application will decrease, and the number of Laravel files increase, until you’re left with nothing of the legacy application.
Happy for you to reach out if you have any questions. DM me on Twitter 𝕏 (https://x.com/martinbean) and I can share my email address.
Glukinho was awarded Best Answer+1000 XP
1mo ago
https://github.com/laravel/envoy/issues/3 ?
@servers(['web' => "user@hostname -p 12345"])
Glukinho wrote a reply+100 XP
1mo ago
https://github.com/laravel/envoy/issues/3 ?
@servers(['web' => "user@hostname -p 12345"])
Glukinho wrote a reply+100 XP
1mo ago
I checked and confirm the same behavior.
See here: https://github.com/laravel/telescope/issues/189#issuecomment-635909972
It's rather old thread, but still applicable to recent versions. I see my HTTP request made from Tinker in Telescope after app()->terminate() in the same tinker session.
Glukinho wrote a reply+100 XP
1mo ago
What will wasChanged() show for Product A? What about for Product B?
How about just try it out yourself? In tinker or some test artisan command.
Glukinho was awarded Best Answer+1000 XP
1mo ago
There are some packages, like this, which seems pretty mature: https://github.com/matanyadaev/laravel-eloquent-spatial
Otherwise you should use something like DB::raw(POINT(100 200)), refer to your database spatial type manual.
It would be nice to see Laravel internal support for such things.
Having simple JSON column seems bad to me as you would want to use DB internal capabilities to calculate area of given polygon or distance between given points. With JSON column you have to calculate them by yourself.
Glukinho liked a comment+100 XP
1mo ago
As of today, AI agents can't make proper apps on their own. What they can do is produce junk that passes tests. To use it for any proper product, you have to understand the code and correct its issues.
It's clear that AI will be useful, but the hype is completely overblown. If you were to go back and read the marketing from two years ago, you'd think you have no future in tech if you didn't use [insert any AI tool hot at the time]. Now those AI models are obsolete, and if you spent the time learning the fundamentals of computer science instead, you'd be much better off.
Some of the recent layoffs in the tech sector can be attributed to pandemic-era over-hiring and the general downturn in the US economy. But I'm sure the over-hyping of generative AI is partly to blame. I believe we'll see more service degradation over the following years.
What you should do ultimately depends on your goals. If you're a non-programmer who wants something on the screen, you may not need to understand the code. I just don't see anyone hiring an "AI prompter" who's helpless when something doesn't work.
Glukinho was awarded Best Answer+1000 XP
1mo ago
Do you need all 80k rows of data for developing?
Can you use some fake data in your local dev database (let's say 100 rows which is easily faked and seeded as often as you want) and have the whole real 80k rows on production database?
Glukinho wrote a reply+100 XP
1mo ago
This can be handled on web server, not Laravel: https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_client_certificate
I tried it once successfully (web server allowed to view a page only after a browser provides valid certificate), but it was only a test out of curiosity, no real implementation.
Glukinho wrote a reply+100 XP
1mo ago
Do you need all 80k rows of data for developing?
Can you use some fake data in your local dev database (let's say 100 rows which is easily faked and seeded as often as you want) and have the whole real 80k rows on production database?
Glukinho wrote a reply+100 XP
1mo ago
There are some packages, like this, which seems pretty mature: https://github.com/matanyadaev/laravel-eloquent-spatial
Otherwise you should use something like DB::raw(POINT(100 200)), refer to your database spatial type manual.
It would be nice to see Laravel internal support for such things.
Having simple JSON column seems bad to me as you would want to use DB internal capabilities to calculate area of given polygon or distance between given points. With JSON column you have to calculate them by yourself.
Glukinho liked a comment+100 XP
1mo ago
@armanhozyn I’ll never understand why Laravel removed this, as it was great for applying to policy methods to resourceful controller actions.
Nevertheless, you can get it back by importing the AuthorizesRequests trait in your controller:
+ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class CommentController extends Controller
{
+ use AuthorizesRequests;
public function __construct()
{
$this->authorizeResource(Comment::class);
}
}
Glukinho wrote a reply+100 XP
1mo ago
abort function puts a message to response body, not in status string. Maybe you should write your own helper function for that.
Glukinho wrote a reply+100 XP
1mo ago
Moving to a model seems more appropriate since this helper interacts with database. Utilize local scope: https://laravel.com/docs/13.x/eloquent#local-scopes
Glukinho wrote a reply+100 XP
1mo ago
v13 came out recently :)
Glukinho liked a comment+100 XP
1mo ago
That's why I miss the good old pencil and paper days. Or at least the old MSDOS days.
Glukinho wrote a reply+100 XP
1mo ago
It's interesting to know what caused the problem.
Glukinho wrote a reply+100 XP
1mo ago
I would use this package: https://github.com/kitloong/laravel-migrations-generator
No matter what you do, Backup first.
+1000000
Glukinho wrote a reply+100 XP
1mo ago
I checked with Firefox 149.0 on Windows and I confirm the problem.
Also "Forum" link in a header doesn't work, browser just doesn't navigate to https://laracasts.com/discuss (other nav links work fine).
Glukinho wrote a reply+100 XP
1mo ago
It's getTitle() method in Filament/<...>Resource/Pages/View<...>.php:
public function getTitle(): string|Htmlable
{
return $this->getRecord()->title;
}
Glukinho wrote a reply+100 XP
1mo ago
I share your view. "A cloud" means "someone else's servers". Having your own gives flexibility and security (if you are really able to manage an infrastructure).
Glukinho wrote a reply+100 XP
1mo ago
It seems it is needless to say such structure is wrong, you probably know that already.
Did you try something like this? https://stackoverflow.com/questions/38608244/laravel-eloquent-query-where-like-relationship
Glukinho wrote a reply+100 XP
1mo ago
It's strange, smtp.gmail.com should provide valid certificate and you should be able to verify it. Are you sure you have this mail host? What config('mail.mailers.smtp.host') shows?
At least the problem is localized, that's good.
Try to add to config/mail.php:
'mailers' => [
'smtp' => [
// ...
'verify_peer' => false,
],
]
And see what happens on sending test mail.
Glukinho wrote a reply+100 XP
1mo ago
Gmail was always tricky for sending emails via SMTP.
Do you get a message if you invoke test sending, using php artisan tinker?
Mail::to('d****@yahoo.com')->send(new TestMail);
Glukinho wrote a reply+100 XP
2mos ago
Using the upper half of the screen for PHPStorm, the lower half for the docs in a browser, and the landscape screen for the actual output made my workflow significantly faster.
You should try three monitors, even more comfortable.