vanilophp / framework

The truly Laravel E-commerce Framework
https://vanilo.io
MIT License
818 stars 102 forks source link

ChannelController@store does not `Slug` as slug #83

Closed S-DICKSON closed 3 years ago

S-DICKSON commented 4 years ago

Question Should the user be allowed to store slugs that is the incorrect format?

$request = [ "name" => "Amazing Channel" "slug" => "Amazing Channel" ];

outcome

$channel->name = Amazing Channel
$channel->slug = Amazing Channel

Expected

$channel->name = Amazing Channel
$channel->slug = amazing_channel

Possible Solution

 Illuminate\Support\Str::slug('Amazing Channel', '-')
 "amazing-channel"

or

https://laravel.com/docs/6.x/validation#prepare-input-for-validation

protected function prepareForValidation()
{
    $this->merge([
        'slug' => Str::slug($this->slug),
    ]);
}
fulopattila122 commented 4 years ago

Slug is autogenerated if left empty but can be set to an arbitrary value.

This is the default behavior, but you're completely free to change this behavior in your application. If you want to use this prepareForValidation() method, the best is to customize the corresponding Form Requests: https://vanilo.io/docs/1.2/form-requests#customizing-form-requests

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed within 3 days if no further activity occurs. Thank you for your contributions.