atishrajput

atishrajput

Member Since 2 Years Ago

Experience Points 1,530
Experience Level 1

3,470 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 0
Lessons
Completed
Best Reply Awards 2
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.

18 Dec
7 months ago

atishrajput left a reply on Error In Laravel 5.7

@ROBSTAR - yes its exactly like as the docs

17 Dec
7 months ago

atishrajput left a reply on Error In Laravel 5.7

Route

Route::group(['middleware'=> 'CheckAge:test'], function() { Route::get('welcome', function() { echo 'Atish Kumar'; }); });

tried both way array and non array but nothing works

atishrajput left a reply on Error In Laravel 5.7

tried everything but nothing works

atishrajput left a reply on Error In Laravel 5.7

yes did but nothing works. i have already mentioned its working with default parameter. so your question is invalid

atishrajput left a reply on Error In Laravel 5.7

@D9705996 - Unable to pass the parameter to laravel middleware group. getting error Class doesn't exists but working with default or without default parameter.

web.php

Route::group(['middleware'=> 'CheckAge:test'], function() { Route::get('welcome', function() { echo 'Atish Kumar'; }); });

File - CheckAge.php

atishrajput started a new conversation Error In Laravel Ver 5.7

Unable to pass the parameter to laravel middleware group. getting error Class doesn't exists but working with default or without default parameter.

web.php

Route::group(['middleware'=> 'CheckAge:test'], function() { Route::get('welcome', function() { echo 'Atish Kumar'; }); });

File - CheckAge.php

atishrajput left a reply on Error In Laravel 5.7

Unable to pass the parameter to laravel middleware group. getting error Class doesn't exists but working with default or without default parameter.

web.php

Route::group(['middleware'=> 'CheckAge:test'], function() { Route::get('welcome', function() { echo 'Atish Kumar'; }); });

File - CheckAge.php

atishrajput started a new conversation If You See A Post Again. Laravel Counts It As A View :)

if you see a post again. laravel counts it as a view :)

atishrajput left a reply on Error In Laravel 5.7

Unable to pass the parameter to laravel middleware group. getting error Class doesn't exists but working with default or without default parameter.

Route Route::group(['middleware'=> 'CheckAge:test'], function() { Route::get('welcome', function() { echo 'Atish Kumar'; }); });

File - CheckAge.php

atishrajput started a new conversation Error In Laravel 5.7

Unable to pass the parameter to laravel middleware group. getting error Class doesn't exists but working with default or without default parameter.

Route Route::group(['middleware'=> 'CheckAge:test'], function() { Route::get('welcome', function() { echo 'Atish Kumar'; }); });

File - CheckAge.php

12 May
1 year ago

atishrajput left a reply on How To Execute A Specific Table Migration?

It's very simple.

just rename the files in ascending order. basically, you have to change the timestamps of files in ascending order.

example:

file:- 2014_1012000000_create_users_table (change time stamp 2014_1012000000)

then use the following command

php artisan migrate:refresh

26 Jul
1 year ago

atishrajput left a reply on $bgprofile Is Undefine

@davy_yg can u plz share the full error & controller & view page code. so i can help you

16 May
2 years ago

atishrajput left a reply on Laravel 5.4 How To Redirect Back Using `->withInput(['key' => $val])`

return redirect()->back()->withInput()->withMessage($with);

05 May
2 years ago

atishrajput left a reply on Insert Database

DB::table('tbl_name')->insert([

'name'=>'atish',
    'contact' => '9876543210'

]);

27 Apr
2 years ago

atishrajput left a reply on AJAX Retrieve Data From Controller - Multiple Parameters

@cre3z

    issue fixed?

try this . if its not working then send me the result & db structure


    $models = DB::table("sesta_assets")->where(["asset_type"=> $asset, "brand" => $brand])->get();

    print_r($models);
26 Apr
2 years ago

atishrajput left a reply on <a> Tag Is Not Working In <li?>

@Kaustubh is this fixed?

 <a href="{{ url('seller/htm',[$products->name])}}">{{ $products->name }}</a>

atishrajput left a reply on AJAX Retrieve Data From Controller - Multiple Parameters

@cre3z

  try this . if its not working then send me the result & db structure


  $models = DB::table("sesta_assets")->where(["asset_type"=> $asset, "brand" => $brand])->get();

   print_r($models);

atishrajput left a reply on AJAX Retrieve Data From Controller - Multiple Parameters

@cre3z

  public function index(Request $request){

  $asset = $request->input('asset'); $brand = $request->input('brand');

  $models = DB::table("sesta_assets")->where(["asset_type"=> $asset, "brand" => $brand])->pluck("brand_model","asset_img");

   return json_encode($models->all());

 }

atishrajput left a reply on AJAX Retrieve Data From Controller - Multiple Parameters

use :)

return json_encode($models->all());

atishrajput left a reply on AJAX Retrieve Data From Controller - Multiple Parameters

can you please share your controller code

atishrajput left a reply on Passing $user_profile To The View

There are many ways in laravel to pass the data in view. examples is below:

return view('soulfy.index_v2', ['user' => $user, 'user_profile' => $user_profile, 'articles' => $articles, 'settings' => $settings]);

OR

return view('soulfy.index_v2', compact('user', 'user_profile', 'articles', 'settings');

atishrajput left a reply on <a> Tag Is Not Working In <li?>

atishrajput left a reply on Storing Session Value To Database

@Kaustubh

  1. create a sessions table
   Schema::create('sessions', function(Blueprint $table) {
        $table->increments('id');
        $table->text('payload');
        $table->integer('last_activity');
        $table->timestamps();
    });


 2. go to app\config\session.php

      change session "driver to database" 

      assign table name to table variable


 return array(
    'driver' => 'database',
    'lifetime' => 120,
    'expire_on_close' => false,
    'table' => 'sessions',
    'path' => '/',
  );
25 Apr
2 years ago

atishrajput left a reply on How To Add Read More Link After Posts Body.

you can use class to design the link

.read-more{ text-decoration: none; color: #000000; font-weight: bold; }

{{ strlen(strip_tags($post->body)) > 50 ? "...ReadMore" : "" }}

atishrajput left a reply on AJAX Retrieve Data From Controller - Multiple Parameters

@cre3z try this

Ajax Code:

$.ajax({ type: 'POST', url: '/test/', data: { asset: asset, brand: brand }, dataType: 'json', success: function (data) { console.log(data); } });

Route Code:

Route::post('test','[email protected]');

Controller Code:

public function index(Request $request){

$asset = $request->input('asset'); $brand = $request->input('brand');

$models = DB::table("sesta_assets")->where(["asset_type"=> $asset, "brand" => $brand])->pluck("brand_model","asset_img");

//print_r($models);

return json_encode($models);

}

atishrajput left a reply on Advice On Session And Shopping Cart

@Shiva use below code :)

foreach($show_session as $sess){

// print_r($sess);

echo $qty = $sess->qty;

}

24 Apr
2 years ago

atishrajput left a reply on Advice On Session And Shopping Cart

also share the customercontroller code

atishrajput left a reply on Advice On Session And Shopping Cart

print_r($show_session);

send me the result

21 Apr
2 years ago

atishrajput left a reply on Text Date Validation

first of all use either "sometime" or "required" not both together

sometimes means if value is not empty then validate (value is not manadtory)

required means always validate value (manadtory)

?start=2017-04-21 (GET REQUEST)

public function totals(Request $request) { $this->validate($request, [ 'aggregated_by' => 'sometimes|in:hour,day,month,year', 'start' => 'sometimes|date_format:Y-m-d', 'end' => 'sometimes|date|after:start', 'limit' => 'sometimes|integer', 'sort' => 'sometimes|in:period,amount', 'order' => 'sometimes|in:asc,desc', ]);

}

atishrajput left a reply on Storing Returned Results From Database In Array And Pass It To View

public function getmedia() { $media=Events::all(); $items = array('Events'); $event; foreach($media as $media) { $event=Media::where('events_id',$media->id)->first(); $items[]=$event;

    }
        return view('event',compact($items));
}

atishrajput left a reply on Can Anyone Help Me How To Calculate Time Differences In Laravel?

create a method

function dateDiff($time1, $time2, $precision = 6) { // If not numeric then convert texts to unix timestamps if (!is_int($time1)) { $time1 = strtotime($time1); } if (!is_int($time2)) { $time2 = strtotime($time2); }

    // If time1 is bigger than time2
    // Then swap time1 and time2
    if ($time1 > $time2) {
        $ttime = $time1;
        $time1 = $time2;
        $time2 = $ttime;
    }
    
    // Set up intervals and diffs arrays
    $intervals = array('year','month','day','hour','minute','second');
    $diffs = array();

    // Loop thru all intervals
    foreach ($intervals as $interval) {
        // Set default diff to 0
        $diffs[$interval] = 0;
        // Create temp time from time1 and interval
        $ttime = strtotime("+1 " . $interval, $time1);
        
            // Loop until temp time is smaller than time2
        while ($time2 >= $ttime) {
            $time1 = $ttime;
        $diffs[$interval]++;
        // Create new temp time from time1 and interval
        $ttime = strtotime("+1 " . $interval, $time1);
        }
    }

    $count = 0;
    $times = array();
    // Loop thru all diffs
    foreach ($diffs as $interval => $value) {
        // Break if we have needed precission
        if ($count >= $precision) {
            break;
        }
        // Add value and interval 
        // if value is bigger than 0
        if ($value > 0) {
            // Add s if value is not 1
        if ($value != 1) {
            $interval .= "s";
        }
        // Add value and interval to times array
        $times[] = $value . " " . $interval;
        $count++;
        }
    }

    // Return string with times
    return implode(", ", $times);
    
}

echo $this->dateDiff('2017-04-21', '2017-03-25')

atishrajput left a reply on Advice On Session And Shopping Cart

  1. you have to create a single table name "carts"

Table Structure:-

cart_id (int auto_increment primary_key)

user_id (int foreign key users table user_id)

data (text)

  1. at the time of logout (before logout)

    $cart_data = Session::get('Cart_session');

    $cart = [

     'user_id' => Auth::id(),
             'data'      => json_encode($cart_data);
    

    ];

$carts_tbl = DB::table('carts')->where(['user_id' => Auth::id()])->first();

if(isset($carts_tbl)){

DB::table('carts')->where(['user_id' => Auth::id()])->update($cart);

} else{ DB::table('carts')->insert($cart); }

Session::flush();

  1. at the time of login (after login)

    $carts_tbl = DB::table('carts')->where(['user_id' => Auth::id()])->first();

    if(isset($carts_tbl)){

      $cart_data = json_decode($carts_tbl->data);
      Session::set('Cart_session',$cart_data);
    

    }

  1. Display Cart

    Session::get('Cart_session');

update cart session when user add or remove products 

atishrajput left a reply on Disable Verify Csrf Token By Middleware

app/Http/Middleware/VerifyCsrfToken.php :

class VerifyCsrfToken extends BaseVerifier {

protected $except = [
    'my-route/*'
];

}

atishrajput left a reply on Htmlentities() Expects Parameter 1 To Be String, Object Given (View: C:\xampp\htdocs\homesteadwithnewacl\resources\views\cpm_view\courier.blade.php)

htmlentities requires string not array or collection

example:- correct approach

$db = DB::table('users')->get();

htmlentities($db->email);

example:- wrong approach

$db = DB::table('users')->get();

htmlentities($db);

atishrajput left a reply on Advice On Session And Shopping Cart

@thoasty we are talking about login users not visitors. amazon saves the cart data if user login

atishrajput left a reply on Composer

open command go to directory where you have installed laravel

run following command

php composer.phar create-project --prefer-dist laravel/laravel blog

you can run all the composer commands in windows using

php composer.phar instead of "composer"

atishrajput left a reply on Advice On Session And Shopping Cart

just create a table carts

cart_id auto increment primary key user_id int data text

cart_session includes the data of a single user. when user logout simply flush all sessions

store:

user_id: Auth::id() . (user login id) data: json_encode(cart_session)

atishrajput left a reply on Advice On Session And Shopping Cart

Session::flush(); removes all the session of current application.

you should use $request->session()->forget('item_name'); to remove particular session.

but from my point of view you should save cart data of users (with user id) into some table so you can display the cart values when user login again. and clear the cart data from table when user remove item from cart or buy item. and use Session::flush(); at the time of logout :)

atishrajput left a reply on Laravel Date Validation

How do I validate a date in such a way that it only accepts a date which is same asa given date, or older than that.

'required|date_format:Y-m-d|before:xxxx'

atishrajput left a reply on Laravel Date Validation

'required|date_format:Y-m-d|after:tomorrow'

you should use either date or date_format not both together

if you want to validate the given date will be greater than current date then you should use after:tomorrow instead of after:today