how to integrate user based permission and role based permission in laravel - laravel-5.4

laravel version : 5.4
Php verision : 5.6
I want to apply permission in my system role based and user based permission.
I can give role based permission. also i want to add one custom role where i can give user based permission , Means for this role two user can have different permission although they are in same group.

Installing the spatie permission in local
1.
Removed : composer.lock and vender
Run :
composer require spatie/laravel-permission:^1
2.
In Laravel 5.5 the service provider will automatically get registered.
In older versions of the framework just add the service provider in config/app.php file:
'providers' => [
// ...
Spatie\Permission\PermissionServiceProvider::class,
];
3.
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"
4.
Run : php artisan migrate
Output :
Migrating: 2018_09_14_114242_add_start_date_to_project_activity_table
Migrated: 2018_09_14_114242_add_start_date_to_project_activity_table
Migrating: 2018_09_14_115119_update_start_date_to_project_activity_table
Migrated: 2018_09_14_115119_update_start_date_to_project_activity_table
Migrating: 2018_09_20_065330_add_project_maintenance_ppa_id_to_project_maintenance_table
Migrated: 2018_09_20_065330_add_project_maintenance_ppa_id_to_project_maintenance_table
Migrating: 2018_09_21_053456_add_project_maintenance_contact_id_to_project_maintenance_table
Migrated: 2018_09_21_053456_add_project_maintenance_contact_id_to_project_maintenance_table
Migrating: 2018_09_24_051933_add_start_date_end_date_to_maintenance_resolution_table
Migrated: 2018_09_24_051933_add_start_date_end_date_to_maintenance_resolution_table
Migrating: 2018_09_28_061855_create_permission_tables
Migrated: 2018_09_28_061855_create_permission_tables
5.
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="config"

Related

How to prisma with local existing database? When i tried i got the following error

This is the error :
reverie-pc#reveriepc-Latitude-3400:~/VasanthkumarV/prisma$ sudo npm install -g prisma
[sudo] password for reverie-pc:
npm WARN deprecated request#2.88.2: request has been deprecated, see
https://github.com/request/request/issues/3142
/usr/bin/prisma -> /usr/lib/node_modules/prisma/dist/index.js
+ prisma#1.34.10
updated 1 package in 29.734s
(base) reverie-pc#reveriepc-Latitude-3400:~/VasanthkumarV/prisma$ prisma init test
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? MySQL
? Does your database contain existing data? Yes
? Enter database host localhost
? Enter database port 3306
? Enter database user root
? Enter database password [hidden]
? Please select the schema you want to introspect database_test
Introspecting database database_test 435ms
Created datamodel definition based on 24 tables.
? Select the programming language for the generated Prisma client Prisma JavaScript Client
Created 3 new files:
prisma.yml Prisma service definition
datamodel.prisma GraphQL SDL-based datamodel (foundation for database)
docker-compose.yml Docker configuration file
Next steps:
1. Open folder: cd test
2. Start your Prisma server: docker-compose up -d
3. Deploy your Prisma service: prisma deploy
4. Read more about introspection:url
▸ Syntax Error: Expected Name, found Int "1"
Get in touch if you need help: https://slack.prisma.io/
To get more detailed output, run $ export DEBUG="*"
(node:14055) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
Generating schema... !
How to resolve this error..and what is the procedure to connect Prisma server with local database (MySQL)?? and what about the prisma deployment??
How to connect prisma with existing db?
It looks like you are using Prisma 1 which is currently in maintenance mode.
Given that this looks like a new project, I'd suggest you take a look at Prisma 2 which includes many improvements and a simpler mental model.

Laravel login timing out

After starting up a new Laravel project, creating the UI with bootstrap, and setting up the auth controllers using:
php artisan make:auth I ran the database migration and seeded a user which came across fine in the remote database. I tried an initial login at the /login and received the error:
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] Operation timed out (SQL: select * from `users` where `email` = redacted#gmail.com limit 1)
http://127.0.0.1:8000/login
I have not modified any files away from the defaults that artisan created. I have however noticed the primary culprit seems to be the email itself is not a string, running the query in MySQL throws the same type of syntax error which i'm assuming is the issue. I'm just not sure ( lacking enough knowledge of Laravel ) to be able to further diagnose.
If more information is required, i'll be happy to provide it.
Add this in your AppServiceProvider.php
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
add this in your config folder databse.php file
'default' => env('DB_CONNECTION', 'mysql')
and first you try
php artisan config:clear
php artisan cache:clear
Try This
DB_HOST=localhost
in databse.php file
'default' => env('DB_CONNECTION', 'mysql')
php artisan config:cache

How from my envoy script to write app version to database?

With laravel 5.8 envoy command I deploy my changes and I need from my envoy script to write app version to database
For this I created console command , which is located in app/Console/Commands/envoyWriteAppVersion.php file,
but I did not find how to assign additive parameter to my consol commad. I tried like :
php artisan envoy:write-app-version "654"
php artisan envoy:write-app-version 654
php artisan envoy:write-app-version app_version=7.654
But I got error :
Too many arguments, expected arguments "command".
This task did not complete successfully on one of your servers
Which is the valid way ?
Thanks!
I found a valid decision to use in my console command method :
$arguments = $this->arguments();
as it is written here https://laravel.com/docs/5.8/artisan#command-io.
and run from console with space :
php artisan envoy:write-app-version 0.101

Laravel 5.4 - Installing Passport

I'm trying to install passport on my Laravel 5.4 project with the help of the Laravel Documentation. But when i'm at this stage :
php artisan passport:install
I have this error :
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'lpo.oauth_clients' doesn't exist (SQL: insert into `oa
uth_clients` (`user_id`, `name`, `secret`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `upd
ated_at`, `created_at`) values (, Laravel Personal Access Client, ruEzLmQYSK5RhfzSximBKoupaXaMcRSR4CvXET0o, http://
localhost, 1, 0, 0, 2017-07-06 08:26:25, 2017-07-06 08:26:25))
[PDOException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'lpo.oauth_clients' doesn't exist
And i should have something like this if it succeed :
Encryption keys generated successfully.
Personal access client created successfully.
Client ID: 1
Client Secret: OUA4IhQj1t3kDRuWZ6N7DQb9h1N3ccXpQw9HS2iz
Password grant client created successfully.
Client ID: 2
Client Secret: oGhkm0EPSjqxJBMkaWNZ6lIuuZoby4ev787yW6cO
I did php artisan migrate before and i had 2 new table : users and migrations.
Thanks for your help
Most likely you skipped one or two of the following steps:
Next, register the Passport service provider in the providers array of your config/app.php configuration file:
Laravel\Passport\PassportServiceProvider::class,
The Passport service provider registers its own database migration directory with the framework, so you should migrate your database after registering the provider. The Passport migrations will create the tables your application needs to store clients and access tokens:
php artisan migrate
Only after that can you run
php artisan passport:install
Laravel 5.4 provides larger default string length which can not be allowed.
Solution :
Modify AppServiceProvider.php file:
use Illuminate\Support\Facades\Schema;
Add the following line to the boot method:
public function boot(){
Schema::defaultStringLength(150);
}

In Drupal 7 theme, drush doesn't work

I need to fix bugs in styles on the site, built on Drupal 7. But when I changed some lines in styles, nothing changed in the browser. When I ran "drush cc all", I saw in my terminal next (full log contains more than 45k simbols):
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'fr_bote.watchdog' doesn't exist: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array
I have no idea how to fix it, please help me! Thanks for advance!
**Edit
drush status
Drupal version : 7.34
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database username : admin
Database name : fr_bote
Database : Connected
Drupal bootstrap : Successful
Drupal user : Guest
Default theme : bote
Administration theme : shiny
PHP configuration : /etc/php5/cli/php.ini
Drush version : 5.0-dev
Drush configuration :
Drupal root : /var/www/my-website
Site path : sites/default
File directory path : sites/default/files
Temporary file directory path : /tmp
there is a solution! the problem was in the settings database. in file php.ini changed fields max_execution_time, and upload_max_filesize at large values, delete the old tables, again made export - import tables and everything worked!
The message is pretty clear:
The Table fr_bote.watchdog is missing in your DB. You have to create it.
I suppose Drush doesn't find your database. You should call it using
drush -r /path/to/drupal -l your.website.url
so that drush finds your installation directory as well as the correct sites/folder, where the settings.php for this site is located.
Maybe to uses sites/default/settings.php as a fallback and gets pointed to an empty database?
The best way to use drush is to getting used to site aliases (e.g. start at https://duckduckgo.com/?q=drush+site-aliases). A site alias defines the root path as well as the base.url of a drupal installation. You can even define aliases to remote drupal installations. Drush connects them via ssh - no need to leave your local shell.