Комментарии:
Hello respected sir title and slug same fill up...plz
Ответитьthanks
ОтветитьI am trying all the time but cant figure out how to fill the Slug-field with the new generated slug at the create blade. i am getting the slug and everything but the slug-field doesnt automaically fill itself. is there kind a trick to do it??
ОтветитьHi, can you make a video on how to handle slugs in languages like arabic or indian etc?
ОтветитьWhat is the use of trans() in blade as you used in label?
ОтветитьCame across this tutorial, just if some one don`t want to use extra package, I`m using mutator on model, for example Product model:
public function setSlugAttribute($value)
{
if(!$value) {
$slug = Str::slug($this->attributes['name']);
if(Product::where('slug',$slug)->exists())
{
$i = 0;
do
{
$i++;
$slug_result = $slug.'-'.$i;
} while (Product::where('slug',$slug_result)->exists());
} else {
$slug_result = $slug;
}
$this->attributes['slug'] = $slug_result;
} else {
$this->attributes['slug'] = $value;
}
}
maybe not super optimized code, but does the trick.
Hi, how to use the slug in url instead of the post id with this case?
Regards
Thank you so much! Really helped me alot! :)
ОтветитьAssuming that you know how to validate in Livewire, you can make this to work with Livewire's live validation by adding this function to the component:
public function updatedTitle($value)
{
$slugged = SlugService::createSlug(Page::class, 'slug', $value);
$this->slug = $slugged;
}
The name of the function is mandatory for this to automatically fire up when a change is made in the input with the wire:model="title" in the form view.
Nice:)
ОтветитьHi, I have a question. Why we need to use package to generate a slug? We can easily achieve this by using jquery. We just need jquery function which will take title text and replace all the special characters, symbols with "-" . It will be easier than using a separate package, I guess.
Please correct me if I'm wrong.
Some time duplicate slug generates and gives errors constraint violation: 1062 Duplicate entry.
ОтветитьCan this work properly with non-latin strings ?
Ответитьthank you for all your tutorials, i learned a lot.
ОтветитьWhy do you still use Jquery? We're in the middle of 2020!
ОтветитьNice! Can we use this same principle for real time validation? What would it be better to do real time validation with livewire?
ОтветитьThank you for the info, by the way you can use the same exact ajax request, while editing the slug manually, using the jquery events like keyUp, blue or anything else. no need to hit the submit button for check. I think it will be more efficient.
Ответить