Is it possible inside a Controller, to return a javascript action and proceed with the controller script?
Example:
Call to Login page:
<li><a href="javascript:" link="{{ route('login') }}" class="popup">logar</a></li>
$('.popup').click(function(ev){
var URL = $(this).attr("link");
window.open(URL,'janela', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
});
Controller
class testeController extends BaseController {
public function teste($process = null)
{
if ($process) {
return function();
}
echo '<script type="text/javascript">window.close()</script>';
if(Auth::check()){
$role = User::find(Auth::user()->id)->roles()->first();
return Redirect::to($role->name)->with('success', 'Logado com sucesso');
}else{
return Redirect::to('/')->with('warning', 'Não foi possível autenticá-lo, tente novamente mais tarde ou nos contate');
}
...
But the echo of javascript does not work inside the controller, only if I give a return , and if I give a return the rest of the controller function does not run .
What is the best procedure in this case?
Attempt1:
class testeController extends BaseController {
public function teste($process = null)
{
if ($process) {
return function();
}
Functions::jsController('close');
if(Auth::check()){
$role = User::find(Auth::user()->id)->roles()->first();
return Redirect::to($role->name)->with('success', 'Logado com sucesso');
}else{
return Redirect::to('/')->with('warning', 'Não foi possível autenticá-lo, tente novamente mais tarde ou nos contate');
}
...
public static function jsController($acao){
if($acao == 'close'){
return '<script type="text/javascript">window.close()</script>';
}
}