mardi 16 juillet 2019

how to fetch the youtue id from youtube url in laravel?

I'm trying to fetch the youtube url id and store only the youtube url id in laravel
This is my store function in VideoController

 $patern=  '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i';

        $user = auth()->user();
        $video = new Video();
        $video->title =$request->input('title');
        $video->description = $request->input('description');
        $video->status =$request->input('status');
        $video->user_id =$user->id;
        $request_youtube_url =$request->input('youtube_url');

        if(preg_match($patern,$request_youtube_url))
        {
        $video->youtube_url =$request_youtube_url;
        }

        $video->save();

        // $validated = $request->validated();
       return Redirect('/videos');
    }





via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire