I have this method:
$user=Sentinel::findById($user->id);
$reminder=Reminder::exists($user)? : Reminder::create($user);
$this->sendEmail($user, $reminder->code);
return redirect()->back()->with(['success'=>'reset code sent']);
However it shows an error, Undefined type 'App\Http\Controllers\Security\Sentinel'
Does anyone know how to remove this error?
After installing the package, open your Laravel config file located at config/app.php and add the following lines.
In the $providers array add the following service provider for this package.
Cartalyst\Sentinel\Laravel\SentinelServiceProvider::class,
In the $aliases array add the following facades for this package.
'Activation' => Cartalyst\Sentinel\Laravel\Facades\Activation::class,
'Reminder' => Cartalyst\Sentinel\Laravel\Facades\Reminder::class,
'Sentinel' => Cartalyst\Sentinel\Laravel\Facades\Sentinel::class,
Source: https://cartalyst.com/manual/sentinel/5.x#laravel-8
Related
I am using the following laravel package for my newsletters:
laravel-newsletter.
I have the following code in my newsletterController.php:
public function index() {
Newsletter::subscribe('rincewind#discworld.com', ['FNAME'=>'Goti', 'LNAME'=>'Loki'], 'test');
return 'Ola !';
}
Now when i go to: /newsletter in my application i see Ola !, but when i open my mailchimp dashboard i see don't see rincewind#discworld.com added to the list of emails for the list test.
I also tried the following method of the mailchimp package:
return Newsletter::isSubscribed('codedevakagautam#gmail.com');
This email address already exists in the list test, i get the following error:
Call to undefined method Spatie\Newsletter\Newsletter::isSubscribed()
What am i doing wrong ? Can somebody please guide me.
Please, verify if you have added an entry to the providers array at your config/app.php
// config/app.php
'providers' => [
...
Spatie\Newsletter\NewsletterServiceProvider::class,
...
];
And at aliases array on the same file
// config/app.php
'aliases' => [
..
'Newsletter' => Spatie\Newsletter\NewsletterFacade::class,
];
Also, you need to import the package on your controller. By doing:
use Newsletter;
Be sure to import this way.
If you did all of the steps above, now you can try to use the method:
return Newsletter::isSubscribed('codedevakagautam#gmail.com');
And to subscribe users to a list, you need to send a 'status' parameter.
The possible values for this field is:
subscribed
unsubscribed
cleaned
pending
See the docs here:
http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/
If this does not work for you, you can have a look at this package:
https://github.com/drewm/mailchimp-api
I am try to use laravel-snappy for pdf generation.
step 1:
run composer require barryvdh/laravel-snappy
step 2:
add in providers Barryvdh\DomPDF\ServiceProvider::class, and aliases 'PDF' => Barryvdh\DomPDF\Facade::class, in app.php
step 3:
create function
public function pdfTest() {
$pdf = App::make('snappy.pdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->inline();
}
then found error:
Class 'App\Http\Controllers\App' not found
How to resolve it.I appreciate all response. Thanks Ahead.
Add a backward slash before this line: \App::make('snappy.pdf.wrapper');
Or add use App; below your namespace.
After processing form input, I redirect to a new route with some flash data:
return Redirect::route('work.index')
->with('flash', 'New work entry has been entered');
In the controller specified by work.index, I try to access the data
$flashed = Session:get('flash');
However, instead of a string, I end up with an array with two sub-arrays, old and new
Am I doing something wrong? Am I supposed to do this?
$flashed = Session::get('flash')['new'][0]
Store Data for next request
Session::flash('city', 'New work entry has been entered');
Retrieve Data from last request
$data = Session::get('city');
return Redirect::route('work.index')
->with('data', $data);
My Advice is to use Laracasts/Flash package that helps you to manage Flash messages in an easy way.
Here the GitHub repo: https://github.com/laracasts/flash
Installation
First, pull in the package through Composer.
"require": {
"laracasts/flash": "~1.0"
}
And then, if using Laravel, include the service provider within app/config/app.php.
'providers' => [
'Laracasts\Flash\FlashServiceProvider'
];
And, for convenience, add a facade alias to this same file at the bottom:
'aliases' => [
'Flash' => 'Laracasts\Flash\Flash'
];
And you can use it with:
Flash::info('Message')
Flash::success('Message')
Flash::error('Message')
Flash::warning('Message')
Flash::overlay('Modal Message', 'Modal Title')
Now in your theme you can easly integrate it with:
#include('flash::message')
NB:
Note that this package is optimized for use with Twitter Bootstrap.
I'm trying to use a Laravel 4 package language file, but I don't know how to do it.
I created a package with php artisan workbench vendor/package --resources. I then create file workbench/vendor/package/src/lang/en/routes.php.
In that routes file a I have this:
<?php
return [
'foo' => 'bar'
];
Now how do I access that? I tried with Lang::get('routes.foo') and Lang::get('vendor/package::routes.foo') but both fails and just gives me the parameter itself I entered. I'm calling it in my service providers boot method.
Same like you call view and config:
// for lang
Lang::get('package::routes.foo')
// or with shortcut func
trans('package::routes.foo')
// for view
View::make('package::view.name');
// for config
Config::get('package::group.option');
What you need to do is to remove vendor/ but leave package.
You can see more at the Laravel documentation on: package conventions.
====
UPDATE
in laravel 5 you can call view and config like this :
// for view (shorthand)
view('path_to_view', array('data' => 'somedata'));
// for config
config('config.name', 'default');
I installed Mailgun for Laravel. I then tried to run the example
$data = [];
Mailgun::send('emails.welcome', $data, function($message)
{
$message->to('foo#example.com', 'John Smith')->subject('Welcome!');
});
But I got the following error:
"Argument 1 passed to Bogardo\\Mailgun\\Mailgun::__construct() must be an instance of Illuminate\\View\\Environment, instance of Illuminate\\View\\Factory given, called in /Users/koushatalebian/CLG/CL2G/app/vendor/bogardo/mailgun/src/Bogardo/Mailgun/MailgunServiceProvider.php on line 33 and defined"
What is going on?
If you are using Laravel 4.2, Please use Illuminate\View\Factory instead of Illuminate\View\Environment.
Bogardo mail gun package pointing wrong file.
/Users/koushatalebian/CLG/CL2G/app/vendor/bogardo/mailgun/src/Bogardo/Mailgun/MailgunServiceProvider.php
View / Pagination Environment Renamed
If you are directly referencing the Illuminate\View\Environment class or
Illuminate\Pagination\Environment class, update your code to reference Illuminate\View\Factory and
Illuminate\Pagination\Factory instead. These two classes have been renamed to better reflect their
function.
Edit:
You can use the correct class by editing the following file:
vendor/bogardo/mailgun/src/Bogardo/Mailgun/Mailgun.php
in Line 5:
remove use Illuminate\View\Environment; and use use Illuminate\View\Factory;
in line 53:
remove
public function __construct(Environment $views)
{
$this->views = $views;
}
use
public function __construct(Factory $views)
{
$this->views = $views;
}
Hope this will fix.