I want to call a function that is in a controller for my form, how do I do it?
Function in FileUploadController
public function hasAnexos(){
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$id = explode("/", $url)[5];
$diretorio = getcwd() . "/app/views/users/tickets/anexos/" . $id;
if (!is_dir($diretorio)) {
return false;
} else {
return true;
}
}
I want to call it in a .blade file
@if(hasAnexos())
<form method="POST" action="download/{{ $ticket->id }}">
<button type="submit" style="margin-top: 3%;" class="btn btn-success"><i class="fa fa-download"></i> Baixar anexos</button>
</form>
@else
<h4>Teste</h4>
@endif