I am using laravel 5.0. I am using Entrust for user permissions.
When I try to do the following function
Entrust::can('customers-views')
I am getting error like this. What is the reason for this. How can I solve this?
Class 'App\Http\Controllers\Entrust' not found
Can I use Entrust:can function in controller?
Can you try doing
\Entrust::can('customers-views')
or add the use path\to\Entrust line at the top of your file.
Related
I have a laravel + Vue.js project template downloaded from Creative Tim. Its login and register is not proceeding, giving the catch error whereas in the template demo its working fine. I think so the instructions said to write the VUE_APP_API_BASE_URL in Vue .env file and I didn't wrote it correct. Can anyone pls tell me how can I locate the exact address and what syntax it would be?
Since you are using vue with laravel, you need to prefix MIX_ before the variable. Eg:
MIX_VUE_APP_API_BASE_URL=http://localhost:8000
Here is the reference: https://laravel.com/docs/8.x/mix#environment-variables
I decided to use PhpStorm for my new Laravel project, so I thought I wanted some autocompletion. I did read the guide from https://blog.jetbrains.com/phpstorm/2015/01/laravel-development-using-phpstorm/ and some of it works fine, but I got a problem.
I wanted to test my DB connection, so I just made a simple index() function like this
if(DB::connection()->getDatabaseName()) {
echo 'Connected to ' . DB::connection()->getDatabaseName();
}
Which works fine, but when I write DB and press Tab I write \DB:: instead of DB::. Then I include use Illuminate\Support\Facades\DB; and DB:: works. But when I added the facade, the autocompletion isn't the same at all and it cant find the methods but they works. It's really annoying.
Someone else had this problem and is there a solution for it?
In PhpStorm,
Settings => plugins
Search repository for laravel and install.
Then after add this package:
composer require barryvdh/laravel-ide-helper
You can find more help on github for this package:https://github.com/barryvdh/laravel-ide-helper
First, install the Laravel plugin for PhpStorm, then install laravel-ide-helper.
After that, generate ide-helper for your project)
php artisan ide-helper:generate
php artisan ide-helper:meta
For correct autocomplete model you must identify this model
use (model namespace)
You have to install the helpers - https://github.com/barryvdh/laravel-ide-helper
Figured it out :) Just att DB to your class and the problem is solved.
use DB;
I'm busy learning laravel from a book for laravel 5.2.
I need to change some things because I'm using laravel 5.3.6 and I'm failing with errors.
I'm trying to create a custom exception when an admin user is trying to go to mysite/admin but the user is not active.
My code and errors: http://laravel.io/bin/PX5oP
Can someone please help?
Ok, changed my code in the admin middleware to this:
throw new NoActiveAccountException;
That solved the problem.
i have installed the chat package:
https://github.com/dazzz1er/confer
Unfortunately i get an error when i try to publish it. Here is the error:
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\Support\Facades\View::composer()
Thanks !
As correctly pointed out by #curious_coder confer is not compatible with Laravel 5.2 yet. Please keep an on the open Laravel 5.2 issue on Github and/or ask the author of this package for updates.
I am trying to install Laravel Spark into an existing app. I have not changed the default namespace of "App".
I get the following error on install:
Class 'Laravel\Spark\Providers\SparkServiceProvider' not found
How can get around this error?
It means you didnt attach a class for laravel to detect it ..
Go to App/Config..open app.php..
scroll down.. youll see a providers list.. add a new line to it like
Laravel\Spark\Providers\SparkServiceProvider::class,
Save and Try again :)