Created
December 25, 2020 18:37
-
-
Save rajeshtva/778db06d20256ad4fce758c59785e9c4 to your computer and use it in GitHub Desktop.
VideoValidationController for my video validation controller file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Rules\VideoDurationValidation; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Validator; | |
class VideoValidationController extends Controller | |
{ | |
public function get_form() | |
{ | |
return view('test'); | |
} | |
public function validate_length(Request $request) | |
{ | |
$validator = Validator::make($request->all(), [ | |
'video' => ['required', 'file', 'mimetypes:video/x-m-asf,video/x-flv,video/mp4,application/x-mpegURL,video/MP2T,video/3gpp,video/quicktime,video/x-msvideo,video/x-ms-wmv,video/avi,video/webm', new VideoDurationValidation(1, 3)] | |
]); | |
// ddd($request->video); | |
// $request->video->move(public_path('data')); | |
if($validator->fails()){ | |
$errors = $validator->errors()->toArray(); | |
$message = reset($errors)[0]; | |
// ddd($errors); | |
return back()->with('error', $message); | |
} | |
return back()->with('success', 'video validated successfully'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment