NithApple

NithApple

Member Since 1 Month Ago

Experience Points
1,800
Total
Experience

3,200 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
9
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
1,800 XP
Feb
09
2 weeks ago
Activity icon

Replied to Get Data From Database

thanks for reply I follow your code now it working fine Thanks so much

Feb
08
2 weeks ago
Activity icon

Started a new Conversation Get Data From Database

can you tell me why? i have created two functions to get data from database and there function select the same table just different status field but the first function getting object and second function getting array object

public function open(){ $lead = Lead::get()->where('status','Open')->toJson(JSON_PRETTY_PRINT); return response($lead, 200); }

public function close(){
    $lead = Lead::get()->where('status','Converted')->toJson(JSON_PRETTY_PRINT);
    return response($lead, 200);
}

result: public function open

{ "1": { "id": 10, "firstname": "admin", "lastname": "apple", "gender": "Male", } }

result : public function close

[ { "id": 8, "firstname": "Sasss", "lastname": "Seksss", "gender": "Male",

} ]

Activity icon

Replied to Multi Auth Using Passport

thanks for reply now i fix already

Feb
06
2 weeks ago
Activity icon

Replied to Access Nested Object

i'm using Laravel Passport whenever i'm login it will be return like that

public function login(){ if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){ $user = Auth::user(); $success['token'] = $user->createToken('crm')-> accessToken; return response()->json(['success' => $success], $this-> successStatus); } else{ return response()->json(['error'=>'Unauthorised'], 401); } }

Activity icon

Started a new Conversation Access Nested Object

how i can get token from this? it get from JSON code in below {success: {…}} success: token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIzIiwianRpIjoiMTU3ZDI4MmRhMDg1ZGQ0NmNjM2Q2ZWMwYWFmOTQ0ZWFjNDYxM2U0ZDEyMzk0NTQ1OGJhOTQ0MzdhYzFlNjRmZmVjY2RlMzEzMmI3ODdmNmMiLCJI" proto: Object proto: Object

Activity icon

Replied to Multi Auth Using Passport

thanks for reply where how i can past this code Passport::tokensCan([ 'manage-order' => 'Manage order scope' 'read-only-order' => 'Read only order scope' ]); this code in link stack overflow that you send me

Activity icon

Started a new Conversation Multi Auth Using Passport

I have multi user that i need whenever user login i can control permission of user example user_a can access to route a and b but user_b can't access to route a I need to do this with Passport I'm a beginner on laravel please tell me step by step thank advance.

Feb
05
3 weeks ago
Activity icon

Replied to Using New Mysqli In Laravel

in config/database.php 'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE','forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ],

    'mysql2' => [
        'driver' => 'mysql',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE2','forge'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'prefix_indexes' => true,
        'strict' => true,
        'engine' => null,
        'options' => extension_loaded('pdo_mysql') ? array_filter([
            PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 
        ]) : [],
    ],

    'mysql3' => [
        'driver' => 'mysql',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE3','db3'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'prefix_indexes' => true,
        'strict' => true,
        'engine' => null,
        'options' => extension_loaded('pdo_mysql') ? array_filter([
            PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
        ]) : [],
    ],

in .env file

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=db1 DB_USERNAME=root DB_PASSWORD=

DB_DATABASE3=db3 DB_DATABASE2=db2

that db1 is a default database you can set new connection in the controllers like below

    $user = new Users;
    $user->setConnection('mysql2');
    dd($user->find(1));
Activity icon

Replied to Using New Mysqli In Laravel

Before changing databases, you need to specify all databases in config/database.php. After that, you can change database connections on runtime (on the fly) but be careful. For example: //Default connection: DB::connection('table')->table('users')->all();

Activity icon

Replied to Dynamic Database When User Login

can i connect with you?

Activity icon

Replied to Dynamic Database When User Login

now i'm using auth

Activity icon

Replied to Dynamic Database When User Login

yes i know but i need dynamic when login i'm using auth

Activity icon

Replied to Dynamic Database When User Login

i have database already but i just want to switch database connection and use the same modal in laravel

Feb
04
3 weeks ago
Activity icon

Replied to Dynamic Database When User Login

my boss let me do this i'm not clearly purpose of him but i think it should be can just change database connection when user login if anyone know help please i trying so long time

Activity icon

Replied to Dynamic Database When User Login

thanks for reply

Activity icon

Replied to Using Auth On A Different Connection Or Database.

Hello sir you working now ? I need like you also can you share your source code?

Activity icon

Started a new Conversation Dynamic Database When User Login

I'm a beginners on laravel I need dynamic database whenever users login example: user_a ->database_a

user_b->database_b

user_c->database_c

Jan
29
4 weeks ago
Activity icon

Replied to Check Permission Before Delete Data

but i'm using laravel passport it the same ?

Activity icon

Started a new Conversation Check Permission Before Delete Data

I'm using Laravel for API and Angular for Front-End whenever Delete Data or Delete Users from database I need to check permission first if user admin deleting we will allow to delete.

Jan
28
4 weeks ago
Activity icon

Replied to Multi-tenancy Using Laravel App

now you are do it success?

Activity icon

Replied to Multi-tenancy Using Laravel App

hello everyone i doing on this also i need to dynamic database using this package but whenever i follow document in official always got error help please

Jan
27
4 weeks ago
Activity icon

Replied to Dynamic Database Connection Laravel Version 6

I need multi database in single project and the same model and also need to set default database in env file I don't need to specify connection name in config/database.php because if i specify connection next time i don't know how much database so i think it should have the packages for do it

Activity icon

Replied to Which Package Possibility Dynamic Database

I need multi database in single project and the same model and also need to set default database in env file I don't need to specify connection name in config/database.php because if i specify connection next time i don't know how much database so i think it should have the packages for do it

Activity icon

Started a new Conversation Which Package Possibility Dynamic Database

I try long time for find package that we can dynamic database in Laravel if anyone know please tell me

Activity icon

Started a new Conversation Global SetConnection In Laravel

i have create project for multi database whenever that i want to get data I'm always need to set connection before get. but i don't need like this i want to set connection to global when i want to use which database i just call by class name that we already connected in global class

//my current function

    $user = new Users; $user->setConnection('mysql2'); dd($user->find(1));
Activity icon

Replied to Multiple Database But The Same Model In Laravel

it's not global that i need it just switch database in global

Activity icon

Replied to Multiple Database But The Same Model In Laravel

if i set it like this $user->setConnection('mysql'); whenever i get data i always need to define like this $user->setConnection('mysql'); we have ways to set it to global or not ?

Activity icon

Replied to Multiple Database But The Same Model In Laravel

ok now it working fine thank you i just specify like below

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=db1 DB_USERNAME=root DB_PASSWORD=

DB_DATABASE3=db3 DB_DATABASE2=db2

Activity icon

Replied to Multiple Database But The Same Model In Laravel

i will get error when i remove DB_DATABASE like this "'database' => env('db3')," but i just want to fix db name don't need to get from .env file

Activity icon

Replied to Multiple Database But The Same Model In Laravel

i got error when i get data from database now when I restart and reserve i got an error like this SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) (SQL: select * from users where users.id = 1 limit 1)

but my database no any password

Activity icon

Replied to Multiple Database But The Same Model In Laravel

no i'm not remove it

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=db1 DB_USERNAME=root DB_PASSWORD=

Activity icon

Replied to Multiple Database But The Same Model In Laravel

i got new error help please SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected (SQL: select * from users where users.id = 1 limit 1)

Activity icon

Replied to Multiple Database But The Same Model In Laravel

// controller that i use for switch connection class UsersController extends Controller { public function getUser(){ $user = new Users; $databaseName = "mysql2"; $user->setConnection($databaseName); $something = $user->all(); dd($something); } }

// Route Route::get('/','[email protected]');

// database config

'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ],

    'mysql2' => [
        'driver' => 'mysql',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'db2'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'prefix_indexes' => true,
        'strict' => true,
        'engine' => null,
        'options' => extension_loaded('pdo_mysql') ? array_filter([
            PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
        ]) : [],
    ],

    'mysql3' => [
        'driver' => 'mysql',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'db1'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'prefix_indexes' => true,
        'strict' => true,
        'engine' => null,
        'options' => extension_loaded('pdo_mysql') ? array_filter([
            PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
        ]) : [],
    ],
Activity icon

Replied to Multiple Database But The Same Model In Laravel

when i changed connection but value still get from old connection

Illuminate\Database\Eloquent\Collection {#254 ▼ #items: array:1 [▼ 0 => App\Users {#255 ▼ #connection: "mysql" #table: "users" #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: true +wasRecentlyCreated: false #attributes: array:2 [▼ "id" => 1 "name" => "nith" ] #original: array:2 [▼ "id" => 1 "name" => "nith" ] #changes: [] #casts: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: [] #touches: [] +timestamps: true #hidden: [] #visible: [] #fillable: [] #guarded: array:1 [▶] } ] }

Activity icon

Replied to Multiple Database But The Same Model In Laravel

already specify

'mysql2' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'db2'), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ],

Activity icon

Replied to Multiple Database But The Same Model In Laravel

i got this error InvalidArgumentException Database [db2] not configured.

Activity icon

Started a new Conversation Multiple Database But The Same Model In Laravel

i have created tree of database 'db1,db2,db3' all db is have the same table is users , in users table has field id and field name i want to create dynamic database whenever user request and the same model also sorry for my bad English thanks.

Jan
26
1 month ago
Activity icon

Started a new Conversation Tenancy In Laravel

what is tenancy in Laravel and why we need it ?

Jan
24
1 month ago
Activity icon

Started a new Conversation Got Error When Install Laravel Tenancy And Run Command Php Artisan Migrate --database=system

$ php artisan migrate --database=system

Illuminate\Database\QueryException : SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'tenancy' (SQL: select * from information_schema.tables where table_schema = tenancy and table_name = migrations and table_type = 'BASE TABLE')

I got this error I don't' know why because I'm a beginner on laravel I trying to use laravel tenancy but always got error can't fix, link official that I follow https://tenancy.dev/docs/hyn/5.4/installation

Jan
23
1 month ago
Activity icon

Replied to Dynamic Database Connection Laravel Version 6

I mean I have lots of databases but i want to use the same model and i will set the default database, the database will dynamically from users request that we can set from the controller sorry for my bad English i hope you will understand me

Activity icon

Replied to Dynamic Database Connection Laravel Version 6

and I need the same model also if I do like this it will work or not? thanks

Activity icon

Started a new Conversation Dynamic Database Connection Laravel Version 6

hello everyone I need to dynamic the database connection when user request from the front end so I mean I'm using laravel for API can you help me this I try to search on google but have only multiple databases is not dynamic