#Hiding url of a page

27 messages · Page 1 of 1 (latest)

potent hatch
#

So I am currently building an app that stores videos and makes them available over the internet.
The problem is that I want the url of each individual page to look somewhat as youtube's rather than just: host/video/23(id number) and still be accessed from the outside.
How would you recommend to achieve this?

I have looked at UUID - they work great when adding and deleting them from the db, but I am unable to edit the entry , getting this error:
Argument #2 ($status) must be of type int, array given,

left eagle
#

The error is quite simple, it askes for an integer but you give an array, so that isnt going to work…

potent hatch
#

How can I overcome this?

#

I don't think I can transform letters into numbers

potent hatch
#

And if that is the case ,why i don't get the same error when I delete the record?!

viral ridge
#

Share code if you expect help with the code. We can't magically guess what's causing the error, so it just becomes an echo chamber of the error you're already given.

rich flame
# potent hatch How can I overcome this?

Follow the stack trace and look where you're passing an array instead of an int. Doubt it would have anything to do with the UUID, but could be wrong. As others mentioned, it's impossible to guess what your error might be

potent hatch
#

Code for model:

use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Video extends Model
{
    use HasFactory, HasUuids;
}```
#

Code for Controller:

public function edit(string $id)
    {
    
        $video = Video::find($id);
        return redirect('video.editor', ['video'=>$video]);
}```
rich flame
potent hatch
#

ok

#

Migration:

Schema::create('videos', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('title');
            $table->text('path');
            $table->text('body')->nullable();
            $table->tinyInteger('call_to_action');
            $table->timestamps();
            $table->timestamp('published_at')->nullable();

        });
    }
#

Error given: Symfony\Component\HttpFoundation\RedirectResponse::__construct(): Argument #2 ($status) must be of type int, array given, called in C:\Users\aLeX\Documents\Laravel\OneApp3\vendor\laravel\framework\src\Illuminate\Routing\Redirector.php on line 211

#

This error only comes in when I am trying to edit the entry data.

#

I have tested it with id and works like a charm

rich flame
#

So yeah, ignoring the code blocks (even though there's an example in the #rules)...

Your redirect is incorrect, because your controller only accepts a string, while you're sending an array. You'd want to use $video->id or something in your case. Though, I'd suggest you to look into route model binding

potent hatch
#

I am using Route::resource

rich flame
#

Yeah okay, this is going nowhere..

potent hatch
#

Sorry bro, php is not my first language

#

So I think you meant -> public function edit(Video $video)

#

and it works

viral ridge
#

Yes that's route model binding

rich flame
potent hatch
#

Thank you for putting up with my mess

snow shell
#

@potent hatch Is your issue solved? It’s unclear if using route–model binding was the solution to your problem or not.