If anyone has the same problem, got the answer from Stackoverflow:
public function all()
{
$data = parent::all();
if( $data['slug'] === '') {
// if the slug is blank, create one from title data
$data['slug'] = str_slug( $data['title'], '-' );
}
return $data;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community