1 month ago

Can you use {id} for some logic and {slug} for others?

Posted 1 month ago by trevorpan

Have just implemented slugs via the Laracasts videos and they work nicelyexcept for existing logic that uses {id}.

One example is the payment gateway:


As you can see above the id is missing for the job.

     * Get the route key for the model.
     * @return string
    public function getRouteKeyName()
        return 'slug';

     * Store a newly created resource in storage.
     * @param $jobId
     * @return Response
     * @throws ValidationException
    public function store($jobId)
        $job = Job::Incomplete()->findOrFail($jobId);
//other logic

Can you use {id} for some logic and {slug} for others? Otherwise, it seems a tremendous amount of work needs to be done to fix this.

Please sign in or create an account to participate in this conversation.