Skip to content

Instantly share code, notes, and snippets.

@dmsysop
Created January 7, 2021 12:34
Show Gist options
  • Save dmsysop/90c611578a4ba54117e17813d9996989 to your computer and use it in GitHub Desktop.
Save dmsysop/90c611578a4ba54117e17813d9996989 to your computer and use it in GitHub Desktop.
AulasController.php
public function store(AulasRulesRequest $request)
{
$input = $request->all();
$tags = $request['hidden-tags'];
$input['tags'] = $tags;
unset($request->tags);
if (!is_null($request->video)) {
$youtubeService = app(GoogleYoutubeService::class);
$getVideoId = $youtubeService->insert($request->all());
$getVideoId = $request->video;
$videoFilePath = '';
// $videoFilePath = \Storage::disk('videos')->put('aulas', $request->file('video'));
$video = Video::create([
'video_title' => $request->name,
'video_description' => strip_tags($request->description),
'video_tags' => [$tags],
'video_path' => $videoFilePath,
'youtube_video_id' => $getVideoId,
'status' => 1,
]);
//Set the video id
$input['video_id'] = $video->id;
$input['video'] = $getVideoId;
}
if ($aula = Aula::create($input)) {
// IMAGEM
if ($request->file('image')) {
$path = \Storage::disk('backend')->put('aulas', $request->file('image'));
$aula->fill(['image' => $path])->save();
}
alert(['title' => 'Sucesso', 'text' => 'Registro adicionado com sucesso!', 'type' => 'success']);
return redirect()->route('admin.aulas.index');
} else {
alert(['title' => 'Error', 'text' => 'Ocorreu um erro durante o processo!', 'type' => 'error']);
return redirect()->back();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment