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() }}
Related
I want to log from within a Laravel blade template. Can I log something using the Laravel logger, or a simple syslog(1, 'my message') would even be better.
You can use logger in blade
{{ logger('Test') }}
You can use laravel helper function
for store information on log use info function
{{ info("print log in blade")}}
for debug level message on log use logger function
Don't add semi colon in the logger function.
//{{ logger('Debug message'); }}
{{ logger('Debug message') }}
You can also do below, especially in Laravel 4.2
And try to load that blade then view your laravel.log file
If you are using a recent version of Laravel, use Telescope.
Link to Install Telescope: https://laravel.com/docs/7.x/telescope
After installing telescope, use the following in any part of your blade file:
Log::debug('Debug Message Goes Here'.)
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]
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 want to include CSS and Javascript with the help of Laravel 5 helper. But I don't know which is there.
href="{{ url() }}/assets/css/bootstrap.css" rel="stylesheet"
I need to load with the helper of laravel. Not to traditional.
Please any suggestion tell me.
In Laravel you can use the provided HTML class for including the CSS and JS in a project
Stylesheet:
{{ HTML::style('css/style.css') }}
Javascript:
{{ HTML::script('js/your_js_file.js') }}
NOTE:
You can also use URL class
JS
{{ URL::asset('js/your_js_file.js'); }}
STYLE
{{ URL::asset('css/style.css'); }}
EDIT:
If you are using LARAVEL 5 find the solution here http://laravel.io/forum/09-20-2014-html-form-class-not-found-in-laravel-5
One way is using : URL::asset('css/file.css');
For using {{ HTML::style('css/style.css') }}, you will have to go through following steps:
Add the following lines in the require section of composer.json file and run composer update "illuminate/html": "5.*".
Register the service provider in config/app.php by adding the following value into the providers array:
'Illuminate\Html\HtmlServiceProvider'
Register facades by adding these two lines in the aliases array:
'Form'=> 'Illuminate\Html\FormFacade',
'HTML'=> 'Illuminate\Html\HtmlFacade'
I would like to store my application settings in database.
In order to get a variable in template, I'm currently using
{{ Config::get('file.variable) }}
and settings are stored in config/file
I would like to create controller SettingsController with public static get and set methods and get variables in template in this way:
{{ Settings::get('var_name') }}
instead of
{{ SettingsController::get('var_name') }}
But I'm getting error: Class 'Settings' not found.
I've tried to set routes:
Route::controller('Settings', 'SettingsController'); and
Route::resource('Settings', 'SettingsController');
But none of the methods works.
Any ideas how to solve this problem?
This should be done using facades, which is already answered here:
How to create custom Facade in Laravel 4