bipin_1611

Member Since 8 Months Ago

Experience Points
11,660
Total
Experience

3,340 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
111
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 3
11,660 XP
Jan
28
2 months ago
Activity icon

Awarded Best Reply on Unable To Get JSON Response Via Web Hooks API.

I found solution. For external calling APIs we do have remove csrf token verification,,

on your App\Http\MiddlewareVerifyCsrfToken.php

add following code:

 protected $except = [
        '/api/real_store_notification/'
    ];

it's should work.

have a good day!!

Activity icon

Replied to Unable To Get JSON Response Via Web Hooks API.

I found solution. For external calling APIs we do have remove csrf token verification,,

on your App\Http\MiddlewareVerifyCsrfToken.php

add following code:

 protected $except = [
        '/api/real_store_notification/'
    ];

it's should work.

have a good day!!

Jan
26
2 months ago
Activity icon

Replied to Object Of Class StdClass Could Not Be Converted To String

could you please show me your code on the model?

Activity icon

Started a new Conversation Unable To Get JSON Response Via Web Hooks API.

I am Using SquareUp(https://developer.squareup.com/) for API. I have set endpoint for webhooks on SquareUp and it's pointing to my domain. But i trying to send test webhooks on the SquareUp it's returning the 200 status code.

Endpoint on the SquareUp:- /domain_url/real_store_notification

On the My Project have call API for that endpoint which entered on the SquareUp.

here is my route api.php

Route::post('real_store_notification', [App\Http\Controllers\RESTAPI\NotificationServicesController::class,'realStoreNotification']);

And i also have kept out from the verifyToken...

here is my App\Http\MiddlewareVerifyCsrfToken.php

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'real_store_notification'
    ];
}

But, i am not getting the response which sent by webhooks.

please let me know if you need anything.

Jan
03
3 months ago
Activity icon

Replied to Laravel 8 - Multi Auth With Two Diffirent Registration Form?

ohh, i forgot to add, loginContrller.

please refer loginController like this

$user_auth = Auth::guard('admin')
                    ->attempt([
                        'email'=>$request->email,
                        'password'=>$request->password
                    ],
                        $request->remember
                    );
                if($user_auth) {
                    return redirect('/admin');
                } else {
                    if ($errors = $this->validateFields($fields)) {
                        return redirect()->route('admin/login')->withErrors($errors);
                    }
                    $errors = 'Please Enter Valid Email ID or Password.';
                    return redirect('admin/login')->withErrors($errors);
                }
                if ($this->hasTooManyLoginAttempts($request)) {
                    $this->fireLockoutEvent($request);
                    return $this->sendLockoutResponse($request);
                }

for the writer,

$user_auth = Auth::guard('writer')
                    ->attempt([
                        'email'=>$request->email,
                        'password'=>$request->password
                    ],
                        $request->remember
                    );
                if($user_auth) {
                    return redirect('/writer');
                } else {
                    if ($errors = $this->validateFields($fields)) {
                        return redirect()->route('writer/login')->withErrors($errors);
                    }
                    $errors = 'Please Enter Valid Email ID or Password.';
                    return redirect('writer/login')->withErrors($errors);
                }
                if ($this->hasTooManyLoginAttempts($request)) {
                    $this->fireLockoutEvent($request);
                    return $this->sendLockoutResponse($request);
                }
Jan
02
3 months ago
Activity icon

Replied to Laravel 8 - Multi Auth With Two Diffirent Registration Form?

Please follow these steps...

I am taking an example for the admin and writer.. so please make changes as per your requirement...

On the Admin model in app/Admin.php and add the following:

  // app/Admin.php
    <?php

    namespace App;

    use Illuminate\Notifications\Notifiable;
    use Illuminate\Foundation\Auth\User as Authenticatable;

    class Admin extends Authenticatable
    {
        use Notifiable;

        protected $guard = 'admin';

        protected $fillable = [
            'name', 'email', 'password',
        ];

        protected $hidden = [
            'password', 'remember_token',
        ];
    }

on the Writer model and replace with the following:

 open the Writer model and replace with the following:

    // app/Writer.php
    <?php

    namespace App;

    use Illuminate\Notifications\Notifiable;
    use Illuminate\Foundation\Auth\User as Authenticatable;

    class Writer extends Authenticatable
    {
        use Notifiable;

        protected $guard = 'writer';

        protected $fillable = [
            'name', 'email', 'password',
        ];

        protected $hidden = [
            'password', 'remember_token',
        ];
    }

Now, Define the guards,

On config/auth.php and add the new guards edit as follows:

 // config/auth.php

    <?php

    [...]
    'guards' => [
        [...]
        'admin' => [
            'driver' => 'session',
            'provider' => 'admins',
        ],
        'writer' => [
            'driver' => 'session',
            'provider' => 'writers',
        ],
    ],
    [...]


   [...]
    'providers' => [
        [...]
        'admins' => [
            'driver' => 'eloquent',
            'model' => App\Admin::class,
        ],
        'writers' => [
            'driver' => 'eloquent',
            'model' => App\Writer::class,
        ],
    ],
    [...]

On add like this routes.web.php

 Route::group(['middleware'=>'auth:admin'], function(){
	 // routes under the admin
});

Route::group(['middleware' =>'auth:writer'], function () {
    // routes under the writer
});

Please make sure logout for particular auth on the logout method like this..

on the logout method..

Auth::guard('writer')->logout();
Auth::guard('admin')->logout();
Activity icon

Replied to Laravel 8 - Multi Auth With Two Diffirent Registration Form?

instead of Auth scaffolding package, Use laravel's Default Authentication like Auth:Guard.

You can create your custom Auth:Guard and it will allow you to login with the different user role.

Activity icon

Awarded Best Reply on Multiple Auth::Guard Check

I found the where the issues is causing. It's Session not expiring.

When you use the your Custom Auth:Guard, on the Logout, you have to specify which guard logging out like this

Auth::guard('name')->logout();

on the Logout method.

Activity icon

Replied to Multiple Auth::Guard Check

I found the where the issues is causing. It's Session not expiring.

When you use the your Custom Auth:Guard, on the Logout, you have to specify which guard logging out like this

Auth::guard('name')->logout();

on the Logout method.

Jan
01
3 months ago
Activity icon

Replied to Multiple Auth::Guard Check

I have used Authenticatable for the both auth guard.

that is why is it conflicting each other?

when i logged in with back it won't let me open any of routes under the default web guard.

here is loginController

$user_auth = Auth::guard('back')
                    ->attempt([
                        'email'=>$request->email,
                        'password'=>$request->password
                    ],
                        $request->remember
                    );
                if($user_auth) {
                    return redirect('backoffice/admin_users');
                } else {
                    if ($errors = $this->validateFields($fields)) {
                        return redirect()->route('login')->withErrors($errors);
                    }
                    $errors = 'Please Enter Valid Email ID or Password.';
                    return redirect('backoffice/login')->withErrors($errors);
                }
                if ($this->hasTooManyLoginAttempts($request)) {
                    $this->fireLockoutEvent($request);
                    return $this->sendLockoutResponse($request);
                }

Activity icon

Replied to Multiple Auth::Guard Check

Yes, i did,

here is,

  public function __construct()
    {
        if (Auth::guard('back')->check() == false) {
            return redirect('backoffice/login');
        }
    }
Activity icon

Replied to Multiple Auth::Guard Check

i updated as per your suggestion, but still i am able to access route under the auth:back.

Any logic in the Middleware?

Dec
31
3 months ago
Activity icon

Started a new Conversation Multiple Auth::Guard Check

I do have two authentication guard called web and back.

I have seperated routes into two middleware for the auth and backoffice.

When i login with web guard, still i am able to open routes which under the back guard.

Her is my auth.php


    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'back' => [
            'driver' => 'session',
            'provider' => 'backs',
        ],
        'api' => [
            'driver' => 'token',
            'provider' => 'users',
            'hash' => false,
        ],
    ],

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],
        'backs' => [
            'driver' => 'eloquent',
            'model' => App\Backoffice\Backoffice::class,
        ],
    ],

heres, is my web.php

 Route::group(['middleware'=>'backoffice'], function(){
	Route::get('admin_users', '[email protected]');
        Route::get('add_users', '[email protected]');
});



Route::group(['middleware' =>'auth:web'], function () {
    Route::get('/home', '[email protected]')->name('home');
    Route::resource('agent','AgentController')->names('agent');
    Route::get('agent/destroy/{id}', '[email protected]');

});

here is middleware backoffice.php

public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard('back')->check() == false && $guard != 'back') {
            $request->session()->flush();
            Auth::logout();
            return redirect('backoffice/login');
        }
        return $next($request);
    }

here is my model.

namespace App\Backoffice;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;


class Backoffice extends Authenticatable
{
    protected $table = 'users';

    protected $guard = 'back';

    protected $guarded =[];
}

please let me know if you need further information.

Nov
09
5 months ago
Activity icon

Started a new Conversation Extracting Values From Nested Json Data In Php

I am trying to access values from JSON. I have created AJAX to retrive data from database. Now i am trying extracting but i am not getting right path here, Please Help me!!

here is JSON Data

JSON
month : "6"
year : "2018"
branch_code : "preprodtesting"
class : "Class-1"
subject
0
title : "Subject One"
criteria
criteria_1 : "Example One"
criteria_2 : "Example Two"
criteria_3 : "Example Three"
criteria_4 : "Example Four"
1
title : "Subject Two"
criteria
criteria_1 : "Example One"
criteria_2 : "Example Two"
criteria_3 : "Example Three"
criteria_4 : "Example Four"
2
title : "Subject Three"
criteria
criteria_1 : "Example One"
criteria_2 : "Example Two"
criteria_3 : "Example Three"
criteria_4 : "Example Four"
3
title : "Subject Four"
criteria
criteria_1 : "Example One"
criteria_2 : "Example Two"
criteria_3 : "Example Three"
criteria_4 : "Example Four"

I wanted to access 'title' Properties,

here is my ajax

success : function(data){
                $(".class-sub option").each(function() {
                    $(this).remove();
                });

                
                var items = [];
                $.each( data, function( key, val ) {
                    items.push( "<option value='" + json_decode(this['Sub_Json_Data'],true) + "'>" + json_decode(this['Sub_Json_Data'], true) + "</option>" );
                });
                $("#subject").append('<option value="none">-- Select --</option>');
                $("#subject").append(items);
            }