Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Obscura2's avatar

Missing required parameter for [Route: render_single_services] [URI: render_single_services/{slug}] [Missing parameter: slug].

Hello folks, A beginner here. I have been using cviebrock/eloquent-sluggable in my project.

Locally everything is working great! I can access links with the same routes and with slugs rather than IDs.

My Route:

Route::get('render_single_services/{slug}', [SingleController::class, 'render_single_services'])->name('render_single_services');

My Service Controller's Store Method has this. Ive used "use Sluggable;" and the other steps in the Model too.

        $service->slug = SlugService::createSlug(Service::class, 'slug', $request->title);

My view -Controller

public function render_single_services(Request $request, $slug)

    {
        .......;
        $service = Service::where("slug", $slug)->first();
        $services = Service::all();
        $remainingservices = Service::all()->except($service->id);
        return view('portal.singleservice', compact('service', 'services', 'remainingservices'));
    }

My View

<ul class="list-arrow">
            @foreach ($services as $service )
            <li><a href="{{ route('render_single_services', $service->slug) }}">{{ $service->title }}</a></li>
            @endforeach
        </ul>

Can anyone tell me why it works locally but as soon as I upload it on Cpanel.. It throws me this error? I would love to know what I have been missing. I'm sorry I read the other threads before asking this here but I still am confused.

0 likes
7 replies
Sinnbeck's avatar

Most likely one of your services is missing a slug. Can you try this?

<ul class="list-arrow">
            @foreach ($services as $service )
             @if(!$service->slug)
                @dd($service)
             @endif
            <li><a href="{{ route('render_single_services', $service->slug) }}">{{ $service->title }}</a></li>
            @endforeach
        </ul>
Obscura2's avatar

So when I DD.. the slug attribute is missing. Should it be showing here?

#attributes: array:6 [▼
    "id" => 1
    "title" => "Building Construction"
    "description" => """
      Construction, also called building construction, the techniques and industry involved in the assembly construction of structures, primarily those used to provid ▶
                  Building design and structural work forms an integral part of our activities. We have been responsible for the construction of a number of landmark  ▶
                  Building or owning a house is among the most amazing things that most people yearn for. We build it using quality, standardized materials. We also e ▶
      """
    "image" => "uploads/service/building_construction.jpg"
    "created_at" => "2023-02-09 07:04:56"
    "updated_at" => "2023-02-09 07:04:56"
  ]
Sinnbeck's avatar

@Obscura2 I would assume so. Check your production database. Is the "slug" column missing perhaps?

Obscura2's avatar

@Sinnbeck The column is present

    public function up()
    {
        Schema::create('services', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->string('slug');
            $table->text('description');
            $table->string('image');
            $table->timestamps();
        });
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@Obscura2 Show the model then. But even if it is there, it might be empty. Check your database to see if it has data. It might be an empty string

Obscura2's avatar

@Sinnbeck I re-imported the database again and now its working! I dont know what was causing it but thankyou for your time Sinnbeck You've been a real help. :) I hope you have a good day. Ill remove the thread now

Sinnbeck's avatar

@Obscura2 Happy to help. You can close the thread by marking a best answer

Btw. A small tip.

        $remainingservices = Service::all()->except($service->id); //before
        $remainingservices = Service::where('id', '<>', $service->id)->get(); //after

or

$services = Service::all();
$remainingservices = $services->except($service->id);
1 like

Please or to participate in this conversation.