I have a table "projects' with a filed 'slug' and 'project_name' . There are 80k entries.
I am trying to update the 'slug' field with a slug of the project_name.
My code is
public function CreateSlug(){
Projects::query()->update(['slug' => (Str::of('Review of '.( 'project_name' ))->slug('-'))]);
}
The updation is happening but the file slug is populated without the content of the 'project_name' field. Its taking 'project_name' as a string. How can I use the field 'project_name' in this code ?
Thanks. Your code has updated the table field 'slug' appropriately. But the problem remains. When I try to use the slug in the url it ends up in 404 error .
I tried it first in sql. But there are few issues. The url. of the slug does not work. But if I enter the slug manually for a row , it works. Raised this in another thread but could not get any proper solution. Thats why trying to do it like this. BTW I am a novice in laravel 8 :).