I wanted to turn the package name into url name as well So when i used laravel helpers inside where() in my controller method i get an error:
My Controller:
use Illuminate\Support\Str;
public function package($package){
$converted = Packages::where('Package_Name',$package)->first();
$package = Str::kebab($converted);
return view('pages.package',[
'package' => $package,
]);
}
My Model:
class Packages extends Model
{
protected $table = 'packages';
protected $fillable = ['Package_Banner_Image','Package_Image','Package_Type','Package_Name','Package_Short_Description','Package_Price','Package_Duration','Package_Level','Package_Location'];
}
My Route:
Route::prefix('/packages')->group(function() {
Route::get('/', 'PackageController@packages')->name('packages');
Route::get('/{package}', 'PackageController@package')->name('packages.show');
});
My Migration:
Schema::create('packages', function (Blueprint $table) {
$table->id();
$table->string('Package_Banner_Image');
$table->string('Package_Image');
$table->string('Package_Type');
$table->string('Package_Name')->unique();
$table->integer('Package_Price');
$table->integer('Package_Duration');
$table->string('Package_Level');
$table->string('Package_Short_Description');
$table->longText('Package_Location');
$table->timestamps();
});