I want to make redirect with parameters in Lumen (as laravel).
For example. It working in laravel
laravel:
return redirect()->route("main")->with("success", "Success!");
Blade:
<h4 class="text-center" >{{ session('success') }} </h4>
In lumen doesn't exists "with()" but i know that via headers can do it
In advance thanks for help.
Lumen dropped session support in past few versions.
If you want, you can use Laravel session package or simply manually set PHP session ex: $_SESSION['success']['Success!'] and then retrieve it {{ $_SESSION['success'] }}.
Answer for Laravel session package [https://stackoverflow.com/a/47055083/9851907]
Related
I've a project upgraded from laravel 5.4 to 7.6.2, everything is ok, except that I'm unable to remove registration and password reset routes from blade using has('password.request').
As per documentation, I use below options as first line inside the web.php route file:
Auth::routes(['register' => false, 'request' => false, 'reset' => false]);
the problem is that the below code is still executed:
#if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
#endif
As suggested around also on stackoverflow, I also removed the ResetPasswordController.php, RegisterController.php and the ForgotPasswordController.php but after runing "composer dump" the route is still available when I call has('password.request').
Obivioulsy if I click on reset request the route don't exist and the user is unable to reset the password, but I want understand if I did it in the right way. My doubt is mostly arount has('password.request'), why return always true?
ok, after two hour of digging... I just discovered that for some reason I had TWO different calls to Auth::routes().
The first one is mine call with all corrects parameters, the second one was at the end of the web.php route file and is empty! so I "reset" my own setting :(
I don't know how can be happen... probabily is a mistake made during the migration process from 5.4 to 7.x
I have this weird problem with my Laravel 5.5 version... I created the auth views using
php artisan make:auth
This command created the views controllers and everything I need to lets get stared to work. But I'm having this visualization problem
As you can see on the register view I have this problem.
The real thing is that "{{ any_command }}" is printing the code that its supose to generate instead of interprating like part of the code. But if I use {!! any_command !!} instead it seems to work propertly. What can happend to my laravel is screwed up. It has nothing to be with the artisan auth method, because I tried to create a new form (using laravel collective form helper) and get the same result.
{{ }} will escape all data before printing. So, if you write any HTML tag inside, it will be escaped and printed as is. Just like your example.
{!! !!} will print unescaped data. This will print the tags correctly, but you have to take care where you use it, because someone could inject unwanted data there.
So, in your case, you should use {!! !!}.
Please, refer to this question: What is the difference between {{ }} and {!! !!} in laravel blade files?
in controller
$cookie=Cookie('rem_username',$username,60);
$cookie1=Cookie('rem_password',$password,60);
return redirect()->action("Logincheck#dashboardvalue")->cookie($cookie)->cookie($cookie1);
the cookies are set ,
how to use this in view page of login
You can use Cookie facade or use cookie helper function
{{ Cookie::get('rem_username') }} OR
{{ cookie('rem_username') }}
May this also work for you:
{{\Illuminate\Support\Facades\Cookie::get('rem_username')}}
How can I get the previous URL visited on the website in Laravel 5.1?
In Laravel 4 I just needed to write it like below:
{{ URL::previous() }}
The cleanest way seems to be using the url() helper:
{{ url()->previous() }}
URL::previous() works for me in my Laravel 5.1 project. Here is Laravel 5.1 doc for previous() method, which is accessible through URL Facade.
You can still try alternatives, in your views you can do:
{{ redirect()->getUrlGenerator()->previous() }}
or:
{{ redirect()->back()->getTargetUrl() }}
I'm using Laravel 4 and rydurham/Sentinel (https://cartalyst.com/manual/sentinel). I'm able to log in users, register users and display the Sentinel views I've customized perfectly fine. The config changes I've made register fine. However, when I include:
{{ Sentinel::check() }}
or
{{ Sentinel::guest() }}
I get the error Class 'Sentinel' not found. I notice there is no Sentinel Facade in $aliases, and running composer dump-autoload does not fix this. Any thoughts?
The problem was that I'm using rydurham/Sentinel and not Cartalyst's Sentinel package. They are two different things. rydurham/Sentinel includes the facades for Sentry though, so you can use:
{{ Sentry::check() }}
{{ Sentry::guest() }}