amitshahc

amitshahc

Member Since 1 Year Ago

Vadodara

Experience Points 3,560
Experience Level 1

1,440 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 31
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

20 May
4 weeks ago

amitshahc left a reply on Override Old Input Values

@GIACOMOM - This is what exactly I wanted to achieve. If I come directly on getting route using route or view, not by redirect and I want some dynamic tab name to be loaed based on the data fetched and it checks the old in view input, then this is required.

08 May
1 month ago

amitshahc left a reply on Validate The Password Reset Token Before Showing The Reset Form

@SNAPEY - That's sound logical. But again if the token is valid then he has to find the matching email id too. so checking combination of the token + email is difficult for the attacker. still it's logical. thanks.

amitshahc left a reply on Model::create($data) With Carbon Dates Fields In $data Returns Carbon Object.

@TISUCHI - @TISUCHI - ``` $data['start_time'] = $dateTimeOperations->getTimestamp($sdate, $startTime, $timezone); //This will return carbon datetime object.

$record = $model::create($data);

// now returned $record->start_time is carbon object and not same as start_time fetched using $record::find(id);

07 May
1 month ago

amitshahc left a reply on Model::create($data) With Carbon Dates Fields In $data Returns Carbon Object.

@TISUCHI - Thanks tisuchi,

But that's not my question.

Just assume there is a start_time[timestamp] field in my table other than created_at, updated_at, deleted_at. And i want to read it. but in both the case of ::create and ::find it returns different format.

Hope you will get the right direction now.

amitshahc started a new conversation Model::create($data) With Carbon Dates Fields In $data Returns Carbon Object.

In my case, using observer, I am trying to save a model object in json format on both events of Create, Update.

  1. When i get $record = $model::create($data); the $record->start_time field remains a Carbon object.
  2. but while updating i fetch that $record using $record = model::find($id); and the $record->start_time is string date format.

Why the difference? how to resolve it?

amitshahc left a reply on Validate The Password Reset Token Before Showing The Reset Form

@SNAPEY - Hi Snapey, Thanks for the answer. this i have already seen somewhere.

  1. Can you elaborate more about weakness in security?
  2. I am using different guards for the different roles. how can i fetch the guard's password reset table name dynamically?
03 May
1 month ago

amitshahc left a reply on Validate The Password Reset Token Before Showing The Reset Form

@SNAPEY - Does it even matter if I just want to know how should I achieve this technically, :P?

But Well yes I have good reasons too,

Firstly, This class only comes in execution when someone clicks a reset password link from his/her email. so no issue of traffic.

Secondly, If the token is expired or used, the user comes to know it only after filling the valid form data. instead, it will notify the user on the landing page itself that you no need to go through this useless exercise.

Finally, It's all about UX and client requirement. we can't say no to at least this.

amitshahc started a new conversation Validate The Password Reset Token Before Showing The Reset Form

I am looking for the code modifications in below class where I can put the token validation before showing the password reset form.

<?php

namespace App\Http\Controllers\ShopmanagerAuth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Password;
use Illuminate\Http\Request;

class ResetPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset requests
    | and uses a simple trait to include this behavior. You're free to
    | explore this trait and override any methods you wish to tweak.
    |
    */

    use ResetsPasswords;

    /**
     * Where to redirect users after login / registration.
     *
     * @var string
     */
    public $redirectTo = '/shopmanager/dashboard';


    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('shopmanager.guest');
    }

    /**
     * Display the password reset view for the given token.
     *
     * If no token is present, display the link request form.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  string|null  $token
     * @return \Illuminate\Http\Response
     */
    public function showResetForm(Request $request, $token = null)
    {
        return view('shopmanager.auth.passwords.reset')->with(
            ['token' => $token, 'email' => $request->email]
        );
    }

    /**
     * Get the broker to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\PasswordBroker
     */
    public function broker()
    {
        return Password::broker('shopmanagers');
    }

    /**
     * Get the guard to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\StatefulGuard
     */
    protected function guard()
    {
        return Auth::guard('shopmanager');
    }

    protected function rules(){
        return [
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|confirmed|min:8,max:20',
        ];
    }
}
04 Apr
2 months ago

amitshahc left a reply on Laravel Blade `@auth` Condition Not Working As Expected

@SNAPEY - "hesto/multi-auth" is the plugin i am using.

Routegroup for shopmanger

Route::group(['middleware' => ['web', 'auth:shopmanager', 'shopmanagerVerified'], 'prefix' => 'shopmanager', 'namespace' => 'Modules\ShopManager\Http\Controllers'],
    function () {
    ...
    }

Routegroup for shopowner

Route::group([
    'middleware' => ['web', 'auth:shopowner', 'shopmanagerVerified'],
    'prefix'     => 'shop',
    'namespace'  => 'Modules\ShopManager\Http\Controllers',
],
    function () {
    ...
    }

amitshahc left a reply on Laravel Blade `@auth` Condition Not Working As Expected

@SNAPEY - I didn't get your point. but as per my above code block to verify current login in user and print dd() it is printing correct user i.e. 'shopowner' who is logged in.

amitshahc left a reply on Laravel Blade `@auth` Condition Not Working As Expected

@BOBBYBOUWMANN - inside my auth.php

  'guards' => [
        'superadmin' => [
            'driver' => 'session',
            'provider' => 'superadmins',
        ],

        'shopowner' => [
            'driver' => 'session',
            'provider' => 'shopowners',
        ],

        'shopadmin' => [
            'driver' => 'session',
            'provider' => 'shopadmins',
        ],

        'shopmanager' => [
            'driver' => 'session',
            'provider' => 'shopmanagers',
        ],
        
        'admin' => [
            'driver' => 'session',
            'provider' => 'admins',
        ],

        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        
    ],

amitshahc started a new conversation Laravel Blade `@auth` Condition Not Working As Expected

I am trying to pick the master blade template dynamically as per the current user roll logged in. (here it should go to the 'shopowner' auth block)

@auth('shopmanager')
@extends('theme::Admins.shopmanager.layout.master')
@endauth

@auth('shopowner')
@extends('theme::Admins.shopowner.layout.master')
@endif

but this always gives error as it tries to compile the 'shopmanager' master template. It is not going into the 'shopmanager' @auth block because it's not printing anything if I print inside that block.

It only works if I completely comment that line.

23 Nov
6 months ago

amitshahc left a reply on How Do You Pass Constructor Parameters When You're Instantiating An Interface Through A Bind?

@MITHRANDIR - That thing I was already doing using this code. but i wanted to set the AuthId in counstuctor of the ShopManagerRepository. so I can pass at the time of making its instance.

... public function __construct(ShopManagerRepository $repo) { $this->repo = $repo;

    $this->middleware(function ($request, $next) {
        $this->repo->setAuthId(Auth::id());//new $repo(Auth::id());
        return $next($request);
    });
}

...

22 Nov
6 months ago

amitshahc left a reply on How Do You Pass Constructor Parameters When You're Instantiating An Interface Through A Bind?

But how can I pass (Auth::id()) to the target class while binding it? I am injecting the interface from the controller Constructor.

... public function register() { $this->app->singleton(ShopManagerRepository::class, ShopManagerEloquent::class); } ...

and in controller: ... public function __construct(ShopManagerRepository $repo) {

    $this->middleware(function ($request, $next) {
        $this->repo = new ShopManagerRepository(Auth::id()); //new $repo(Auth::id());
        return $next($request);
    });
}

...

nothing works.

05 Nov
7 months ago

amitshahc left a reply on Laravel 5.1 Custom HTTP Status Code And Status Text

Laravel version: 5.5

I am trying to return custom http status code from the laravel controller. (Calling this url using jQuery Ajax $.get())

In my controller function I tried both the way mentioned bellow but it's not working.

  1. This one returns error "Method setStatusCode does not exist."

    return response()->setStatusCode(202);
    
  2. This one not throwing error but returning 200 always.

    $response = new Response();
    $response->setStatusCode(202);
    $response->header('custom', 555);
    return $response;`
    

Below is also not returning 200 ok:

return response()->json("response content", 202);
//or
return response()->make("response content", 202);
01 Nov
7 months ago

amitshahc left a reply on Undefined Method RouteNotificationFor While Saving Notification To Database

Did you find the solutions? I am getting the same error.

27 Oct
7 months ago

amitshahc left a reply on Laravel Pagination Showing Current Items Count Numbers

Update:

@Mithridates why so complex logic when it can be obtain by simple, understandable and logically visible code computation. ... Showing {{ $shops->firstItem()}} to {{ $shops->firstItem() + $shops->perpage()-1 }} of total {{$shops->total()}} entries ...

26 Oct
7 months ago

amitshahc left a reply on Laravel Pagination Showing Current Items Count Numbers

@Mithridates answer worked but wondering how come {{($shops->currentpage()-1)*$shops->perpage()+1}} evaluates. because if current page is 1 then it will be something (1-1) i.e. 0*anything = 0

11 Oct
8 months ago

amitshahc left a reply on Auth::user() Return Null In Construct.

@ModestasV 's answer worked for me.