abhijeet9920

abhijeet9920

Web Developer at BDO LLP, India

Member Since 4 Years Ago

Mumbai

Experience Points
14,390
Total
Experience

610 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
121
Lessons
Completed
Best Reply Awards
3
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.

Level 3
14,390 XP
Jul
24
2 weeks ago
Activity icon

Replied to Put REQUEST 404 Not Found

Hello @nickywan123 ,

How is user is able to update current article? Is user first clicks on Edit first then again he clicks on Save button?

Why don't you write the fetch function in editArticle() function itself rather than doing inside addArticle()?

Activity icon

Replied to Laravel BelongTO Relationship Not Fetching Data

Hello @vidhyaprakash85 sir,

You might need to pass user id in excel. I think in your student table value for advisorId column is null.

Jun
15
1 month ago
Activity icon

Replied to Retrieve Value Using Helping Method Config()

Hello @aronaman

I'll suggest create your php file named settings.php inside config directory

<?php

return [
    "seo_meta_description" => "<your_value>",
];

You can access this like

config('settings.seo_meta_description')

Laravel cache these settings whenever you run php artisan config:cache

Jun
12
1 month ago
Activity icon

Replied to How To Add Select Option In Multi Dynamic Form?

You should use class insetad of an Id since Id can not be duplicate. Or you can make dynamic id say country_id_1, country_id_2 etc. Use jqeury selector for id starts with country

    $('[id^="country_id_"]').on('change', function(){
        //Your logic
    });

You'll find more here

Activity icon

Replied to HELP With DataBase Seeding

Hello @amireix

Faker already have methods to get interval from start time.

$date = $faker->dateTimeBetween('-1 months','+2 months');
$pickupDate = $faker->dateTimeInInterval($date, '+ 5 days'),

I think this should work.

You can refer this

Jun
11
2 months ago
Activity icon

Awarded Best Reply on Route/API Convention Questions

Hello @gabotronix ,

As per my opinion,

  • A category can have multiple subcategories and vice versa
  • A product can not have category. It belongs to category.
  • A product may belong to multiple categories depends on system requirements. However, this will be in a rare case.

So your parent entity should be a category and not a product. Based on this following can be set of routes.

<?php
	//For categories
	Route::get('/category', 'Web\[email protected]');
	Route::get('/category/{id}', 'Web\[email protected]');
	Route::get('/category/{id}/products', 'Web\[email protected]');
	Route::get('/category/{id}/products/{id}', 'Web\[email protected]');

	//For products
	Route::get('/product','Web\[email protected]');
	Route::get('/product/{id}','Web\[email protected]');
?>

You can,

  • Write test cases for controllers
  • You can apply route filters for single/multiple routes. You can even use App\Providers\RouteServiceProvider class for adding route filters for all integer or string route parameters. You can even use regex.
  • You can make a custom Laravel Request class. You can validate all your request, this make sure data being passed to controller will always be clean and valid. You can reuse these request classes.

For your approach

<?php
	/products?category=1
?>

It looks simple. There is only one entry point. You have to maintain a set of switch cases that redirect to actual business logic depending on the query string. However in this,

  • If you wish to add validations to your request, you can't do that.
  • You can't use Laravel Request class.
  • You can't use Route Model binding, in which request parameter acts as Laravel Illuminate\Database\Eloquent\Model class object.
  • How you're going to write test cases in your approach. You must think of that also. There is a separate layer between business logic and route which is known as entry point. You have to write a test case for this layer also. (I may wrong for this point.)

I think you should avoid a single entry point.

Jun
04
2 months ago
Activity icon

Commented on PHP Error Detection And Code Sniffing

Hello Jeffrey,

In one of your video you disabled the status bar of sublime. Can you please give me that video link if possible. It will be good if you tell me name of that key. Thank you

May
05
3 months ago
Activity icon

Commented on Lookaheads And Lookbehinds

Thanks for this amazing tutorial, it helps us a lot. I'm feeling a little confusion between (?:<) and (?=<)

Apr
28
3 months ago
Activity icon

Replied to Is It Best Practice If I Store Model Data In $request?

Hello @tonviet712

I am not sure whether this is an acceptable approach or not, but there is another way of doing this. Create Laravel Form Request. You can validate these requests by adding your own rules. Laravel provides some basic validation rules for checking whether the given input exists in database tables or not. You can use these rules.

For your problem, you can use the rule exists.

    'state' => 'exists:member,code';

Hope this will helps you.

Activity icon

Replied to Record Specific Data To Table With 30minute Time Interval Using Laravel

Hello @ravindu

You can do this by using Laravel Schedulers.

Create a console command which will do this task for you. You can set this command to run automatically every thirty minutes by adding below lines to your Console/Kernel.php.

<?php

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{

    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //List of all user defined console commands
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command(<your_command>)->everyThirtyMinutes();
    }

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        //
    }
}

?>
Apr
24
3 months ago
Activity icon

Replied to Where Are You All From?

Hi @brayniverse , Cheers from India

Activity icon

Replied to Method('PUT') Issue With Blade

Hello @swimmer,

I think you've defined your Route as a POST instead of PUT. Try declaring as PUT. It may solve your peoblem

Apr
21
3 months ago
Activity icon

Replied to Display Countries And State Drop Down Where The State Dependent On The Country

What do you mean by ** You're just using package**? Are you have a JSON file which you are using as a data source? How your package is maintaining data for your country and state? I would suggest storing data in tables and use Laravel Models, You can then use Eloquent relationships, Route model bindings.

Activity icon

Replied to Route/API Convention Questions

Hello @gabotronix ,

As per my opinion,

  • A category can have multiple subcategories and vice versa
  • A product can not have category. It belongs to category.
  • A product may belong to multiple categories depends on system requirements. However, this will be in a rare case.

So your parent entity should be a category and not a product. Based on this following can be set of routes.

<?php
	//For categories
	Route::get('/category', 'Web\[email protected]');
	Route::get('/category/{id}', 'Web\[email protected]');
	Route::get('/category/{id}/products', 'Web\[email protected]');
	Route::get('/category/{id}/products/{id}', 'Web\[email protected]');

	//For products
	Route::get('/product','Web\[email protected]');
	Route::get('/product/{id}','Web\[email protected]');
?>

You can,

  • Write test cases for controllers
  • You can apply route filters for single/multiple routes. You can even use App\Providers\RouteServiceProvider class for adding route filters for all integer or string route parameters. You can even use regex.
  • You can make a custom Laravel Request class. You can validate all your request, this make sure data being passed to controller will always be clean and valid. You can reuse these request classes.

For your approach

<?php
	/products?category=1
?>

It looks simple. There is only one entry point. You have to maintain a set of switch cases that redirect to actual business logic depending on the query string. However in this,

  • If you wish to add validations to your request, you can't do that.
  • You can't use Laravel Request class.
  • You can't use Route Model binding, in which request parameter acts as Laravel Illuminate\Database\Eloquent\Model class object.
  • How you're going to write test cases in your approach. You must think of that also. There is a separate layer between business logic and route which is known as entry point. You have to write a test case for this layer also. (I may wrong for this point.)

I think you should avoid a single entry point.

Activity icon

Replied to Display Countries And State Drop Down Where The State Dependent On The Country

Hello @archaana,

You can do that using jquery and AJAX. You have to create a separate method that returns all states based on their respective country ids.

<?php
public function states($country_id){
	//Assuming you've created States model for `States table
	$states = States::where('country_id', $country_id)->select('id','name')->get();
	return response()->json($states);
}
?>

This will returns all states for given country id. You have to use this URL in AJAX.

//Id of yoyr country dropdown
$("#country").on('change', function(){
	var selectedCountry = $("#country option:selected").val();
    	$.ajax({
        	url: "<route_for_above_function>",
        	success: function(response){
        		var html = '';
        		$("#country").html(''); //For clearing old option list
        		for(var i = 0; i < response.length; i++) {
        	    		var obj = response[i];
        	    		html += '<option value="'+obj.id+'">'+obj.name+'</option>';
        		}
        		$("#country").html(html);
        	}
    	});
});

You can also visit here.

Apr
20
3 months ago
Activity icon

Replied to Error Missing Requiered Parameters

Your question seems incomplete. Please provide some more information.

Activity icon

Replied to HTML Elements Having Opening Tag But No Closing Tag While Displaying Data Created Using Summernote

Hello @srichakra ,

Is this a plain paragraph content which you're rendering from a table or some text with images?

Activity icon

Replied to 419 - Session Expired Without Event Authentication After Deployment | Laravel 5.7

Even a dumb question makes a valid point, so no problem. It will be really helpful if you give a sample code. If I'm not wrong, you're working on API authentication.

You can visit here. This will be really helpful to you.

Activity icon

Replied to Please Make Sure The PHP Redis Extension Is Installed And Enabled

Hello @melodycasinillo ,

Before using redis, make sure php-redis library is properly configured. To check if redis is enabled, create a new info.php file. Add below line

<?php phpinfo(); ?>

And search for redis keyword.

You can also run below commands

php.exe -i | findStr -i "mongo" #for windows
php -i | grep -i "mongo" # for linux

If missing, please refer following guides

Activity icon

Replied to 419 - Session Expired Without Event Authentication After Deployment | Laravel 5.7

Hello @hussain_nayani ,

From your explanation, I'm assuming that you've created two web services for signing a user and registering a user. Laravel has a built-in mechanism for CSRF protection. In all POST requests, additional csrf_token is expected as a parameter, and this parameter is being checked on serverside. You can generate csrf token using

csrf_token();//helper
//or
//
<form method="POST" action="/profile">
    @csrf
    ...
</form>

Please go through documentation.

You can disable this csrf protection by specifying your routes as you've done

<?php
namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        "api/login",
        "api/register"
    ];
}

However, this may not be good practice, since in the future you may need to work on API with either GET or POST or whatever methods.

Another simple solution is to use api.php file for your API routes. It's already there in routes directory from 5.3. If you go to Kernal.php, you'll see two middleware groups.web middleware group is applicable for your web routes, i.e. routes you've added in web.php file, and api group is applicable for routes added in api.php file. A class VerifyCsrfToken is being called only for web routes.

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{

    ...
    protected $middlewareGroups = [
        'web' => [
            ...
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
        'api' => [
            ...,
        ],
    ];
    ...
}

I would suggest you add these two routes in api.php.

Apology for the long explanation.

Activity icon

Replied to Debugbar App Not Showing

Hello,

Assuming you're using Laravel Debugbar. Debugbar will enable, when APP_DEBUG key is set as true in .env file. Please check if this value is set properly. Please follow link for installation and proper usage.

Thank you.

Activity icon

Awarded Best Reply on Array Search With Array()

Hello @jeevamugunthan ,

Based on your request, I think below solution will help you. With

<?php
    $worker=array(1,2,3,4);
    $other=array(1,2,4);
    $found = [];
    $not_found = [];
    foreach($worker as $item){
        if(in_array($item, $other))
            $found[] = $item;
        else
            $not_found[] = $item;
    }
    return ['found' => $found, 'not_found' => $not_found];
?>

With using array functions


<?php
    $diff_result = array_diff($worker, $other);
    return $diff_result;
?>

In both examples, we are searching every element from $worker array in $other array.

You can visit php array_diff.

Hope this helps you.

Activity icon

Replied to Error Missing Required Parameter

Hello @kabiri ,

Please share proper code snippets, as we can't visualize your problem.

Activity icon

Replied to Array Search With Array()

Hello @jeevamugunthan ,

Based on your request, I think below solution will help you. With

<?php
    $worker=array(1,2,3,4);
    $other=array(1,2,4);
    $found = [];
    $not_found = [];
    foreach($worker as $item){
        if(in_array($item, $other))
            $found[] = $item;
        else
            $not_found[] = $item;
    }
    return ['found' => $found, 'not_found' => $not_found];
?>

With using array functions


<?php
    $diff_result = array_diff($worker, $other);
    return $diff_result;
?>

In both examples, we are searching every element from $worker array in $other array.

You can visit php array_diff.

Hope this helps you.