I have problems with setting up entrust with L5..1.4
this is what i do:
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Zizaco\Entrust\EntrustServiceProvider::class,
and this: ....
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Entrust' => Zizaco\Entrust\EntrustFacade::class,
And its not working ... crashes my whole php artisan (when i run php artisan):
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\Foundation\Application::bindShared()
i used this to install entrust:
"zizaco/entrust": "dev-laravel-5"
and then composer update. Now EntrustServiceProvider is under vendor/zizaco/entrust/src/entrust/ ...
any ideas?
After adding
"zizaco/entrust": "dev-laravel-5"
to your composer.json file run:
composer install
Next in the config\app.php add to the providers array:
'Zizaco\Entrust\EntrustServiceProvider',
and under the aliases array add:
'Entrust' => 'Zizaco\Entrust\EntrustFacade',
next run:
php artisan entrust:migration
this will generate the Entrust migration and finally run the migrations:
php artisan migrate
you should now be on your way! For more information check out:
https://github.com/Zizaco/entrust
Related
I'm using nWidart package to manager Laravel app using modules.
I perform a migrate on Settings module.
php artisan module:make-migration create_locations_table Settings
php artisan module:migrate Settings
It's ok!
When I make a seeder:
php artisan module:make-seed Locations Settings => It worked!
But: php artisan module:seed Settings
<?php
namespace Modules\Settings\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class LocationsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* #return void
*/
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
$data = [
'id' => '1',
'name' => 'Hà Nội',
'parent_id' => NULL,
'type' => '1',
'district_id' => NULL,
'province_id' => NULL,
'country_id' => '79162',
'created_at' => '2020-03-26 12:01:08',
'updated_at' => '2020-03-26 12:01:08'
];
DB::table('locations')->insert($data);
}
}
The output is empty!
I think it doesn't go to the LocationsTableSeeder file because when I try dd(1) on it, the output is empty too
Can you help me?
Thanks so much!
Since you're using laravel/framework 5.7.*, you might want to install nwidart/laravel-modules ^4.0 as it is the proper version for you laravel version. See compatibilty.
If that still doesn't work, do this for the meantime:
php artisan db:seed --class=Modules\Settings\Database\Seeders\LocationsTableSeeder
Way forward
Since your project is pretty far behind. I doubt that they will provide any support for this anymore. Upgrading your laravel to ^7.x and laravel-modules to ^7.0 may fix this since there had been an issue about this and has been fixed in the latest versions.
I am new in laravel.I try to build form with laravel collective.I update laravel for collective by composer require laravelcollective/html then add in app.php Collective\Html\ HtmlServiceProvide::class in providers add add
Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\FormFacade::class
in aliases
But it displays errors in these three updated things in providers & aliases(Collective\Html\FormFacade type not defined) and in browser it displays error(form not defined)
Any help?please
First check that you capitalized Form Then try to clear config cache
php artisan config:cache
If you still have a problem you can go to composer.json and check that laravelcollective required then try to run this:
composer update
add your new provider to the providers array of config/app.php:
'providers' => [
// ...
'Collective\Html\HtmlServiceProvider',
// ...
],
add two class aliases to the aliases array of config/app.php:
'aliases' => [
// ...
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
// ...
],
then hit blow command in your working directory.
composer dump-autoload
php artisan view:clear
On my localhost is fine, but when i upload on my server i got this error:
"Class 'Maatwebsite\Excel\ExcelServiceProvider' not found"
My config/app.php:
'providers' => [
...
/*
* Package Service Providers...
*/
Maatwebsite\Excel\ExcelServiceProvider::class,
..
],
'aliases' => [
...
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
],
my laravel version is 5.7
Try running composer dump-autoload in your command line
I have tried to upgrade laravel 5.3 from 5.2 and I am getting following error while php artisan clear-compiled
Class App\Providers\BroadcastServiceProvider contains 1 abstract
method and must therefore be declared abstract or implement the
remaining methods (Illuminate\Support\ServiceProvider::register)
However, I had not facing such an issue while upgrade in my local environment.
The config/broadcasting.php is as:
<?php
return [
'default' => env('BROADCAST_DRIVER', 'log'),
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY'),
'secret' => env('PUSHER_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
],
];
The app/Providers/BroadcastServiceProvider.php is as:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast;
class BroadcastServiceProvider extends ServiceProvider
{
public function boot()
{
Broadcast::routes();
Broadcast::channel('App.User.{userId}', function ($user, $userId) {
return (int) $user->id === (int) $userId;
});
}
}
And .env is as:
CACHE_DRIVER=file
SESSION_DRIVER=file
#BROADCAST_DRIVER=pusher
PUSHER_KEY=someKey
PUSHER_SECRET=SomeSecrete
PUSHER_APP_ID=SomeId
I tried setting default broadcasting driver to log, but seems not working.
Any command I am running like:
php artisan cache:clear Or php artisan config:clear Or php artisan view:clear Or php artisan clear-compiled, I am facing the same error.
I also tried using composer dump-autoload, it works fine but after that if I run php artisan clear-compiled again then also facing the same error.
Please help me.
Looks like you didn't realy update the framework, because Illuminate\Support\ServiceProvider::register method is present in 5.2 and not in 5.3
Double check your update
I have fixed this error by running following artisan commands before updating the composer to upgrade to laravel 5.3.
The commands are:
php artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan clear-compiled
and then do
composer update
It will solve the said error while upgrading to laravel 5.3.
I have used symfony2 console to create database. If I want to create a database named "symfony" I usually mentioned that name in parameters.yml file and run the below command in console
php app/console doctrine:database:create
But when came to laravel, I don't find similar command to create database in laravel. Can anyone help me to find out those command to create database directly from Laravel Console.
You can do that but you will have to create your own command.
First, run php artisan command:make CreateDatabase --command=database:create to generate app/commands/CreateDatabase.php
Then open that file and change it to this: (I left out all comments, but you can obviously keep them in there)
class CreateDatabase extends Command {
protected $name = 'database:create';
protected $description = 'Command description.';
public function fire()
{
DB::statement('CREATE DATABASE '.$this->argument('name'));
}
protected function getArguments()
{
return array(
array('name', InputArgument::REQUIRED, 'Database name'),
);
}
}
Now you only have to register the command in app/start/artisan.php:
Artisan::add(new CreateDatabase);
and you're good to go.
That's how you call it:
php artisan database:create your-desired-database-name
Alternative: artisan tinker
You can always use php artisan tinker to run PHP code (with Laravel bootstrapped):
php artisan tinker
> DB::statement('CREATE DATABASE your-desired-database-name');
As far as I know, you can use php artisan migrate to make migrations including creating tables from Laravel Console. However, you need to create and modify migration files first, where you can create or drop tables.
So if you want to create a table directly from Laravel Console using something like php artisan create database table ***, it is not possible.
I think you can not create database through command so go to app/config/database.php and set your database configuration. details here
'mysql' => array(
'read' => array(
'host' => '192.168.1.1',
),
'write' => array(
'host' => '196.168.1.2'
),
'driver' => 'mysql',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
after setting you can create table through command
php artisan migrate:make create_user_table --table=users
it will generate a file to app/database/migrations name create_users_table. . . . . then you create your table following this link
and finally run this command php artisan migrate