Skip to content

Instantly share code, notes, and snippets.

@rajeshtva
Created December 25, 2020 18:37
Show Gist options
  • Save rajeshtva/778db06d20256ad4fce758c59785e9c4 to your computer and use it in GitHub Desktop.
Save rajeshtva/778db06d20256ad4fce758c59785e9c4 to your computer and use it in GitHub Desktop.
VideoValidationController for my video validation controller file
<?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