ajithlal

ajithlal

Member Since 7 Months Ago

Web developer at Ernakulam

Experience Points 12,470
Experience Level 3

2,530 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 70
Lessons
Completed
Best Reply Awards 7
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.

14 Aug
1 month ago
09 Aug
1 month ago

ajithlal left a reply on Mail Send Working In Localhost Getting Error On Godaddy Server

if you are using gmail then change your MAIL_HOST to MAIL_HOST=smtp.gmail.com

ajithlal left a reply on "Class 'App\Http\Controllers\test' Not Found" Please Check My Code Where I Going Wrong?

you are not included test model. please include model test to your controller

08 Aug
1 month ago

ajithlal left a reply on How Can I Use Two Different Template For Same Route In Laravel

you can use @guest I think. I'm not sure it is a best practice or not.

ajithlal left a reply on Update Status Field Value While Soft Deleting A Record

@click the deleted_at is populated after i run the code. but the status is not changing. So i do the status changing in deleting event.

I've solved it already.

thanks for your support :)

07 Aug
1 month ago

ajithlal left a reply on Update Status Field Value While Soft Deleting A Record

Thanks. That has been fixed by overriding the boot method like this.

public static function boot()
    {
        parent::boot();
        self::deleting(function ($model) {
            $model->status = static::STATUS_DELETED;
            $model->save();
        });
    }

ajithlal started a new conversation Update Status Field Value While Soft Deleting A Record

Hi,

I'm using softDelete to delete a record. I want to update my status field value before soft deleting the record. Here is my delete code.

public function destroy($id)
    {
        try {
            $booking = Booking::findOrFail($id);
            $booking->status = Booking::STATUS_DELETED;
            if ($booking->save()) {
                $booking->delete();
            }

            return redirect()->route('bookings.booking.index')
                ->with('success_message', trans('bookings.model_was_deleted'));
        } catch (Exception $exception) {
            return back()->withInput()
                ->withErrors(['unexpected_error' => trans('bookings.unexpected_error')]);
        }
    }

but the status is not changing

ajithlal left a reply on Create New Item

the above error states that, you have two parameters on your controller and you are passing nothing. if you are submitting a form then pass the book id as hidden input. not as parameter

06 Aug
1 month ago

ajithlal left a reply on Create New Item

can you be more precise. from where you are creating book item what is your exact criteria?

if you have a route() for creating book item from book index like route('book.item.create') then pass id of the book through the URL like

route('book.item.create',$book->id)

then on route.php write

Route::get('book/item/{$id}','[email protected]')->name('book.item.create');

then on your controller you can pass the booking id to form

........
........
ExampleController extends Controller
{
//your other functions
    public function create($id)
    {
        return view('booking.item',compact('id'));
    }
//your other functions
}

ajithlal left a reply on Create New Item

pass book_id as hidden field in form

ajithlal left a reply on Create New Item

if can pass the book_id as hidden variable

ajithlal left a reply on Create New Item

you can pass the $book->id as a variable in your route() like route('route.name',{id of the book}). Then find the book model/object using the book_id.

$book = BookModel::findOrFail($book_id);

ajithlal left a reply on Checking For Null Values In A User Object

@nakov understood. as I'm new to laravel i'm not familiar with this kind of code. that's why I asked the above question. If your method of code execution is more effective then, one who visit the discussion can also use the same. :)

ajithlal left a reply on Checking For Null Values In A User Object

@nakov what will be the benefit of doing this over simple if condition?

ajithlal left a reply on Checking For Null Values In A User Object

if else ladder? or using OR condition in single if

ajithlal left a reply on Checking For Null Values In A User Object

check is_null($user->sex) || is_null($user->phone) like this.

ajithlal left a reply on Session Getting Destroyed After Payment Gateway Redirecting To Success Callback Url.

maybe you can store the value to db before requesting payment to paypal and update the payment status and other fields that can be filled after successful payment. if the payment fails then you can delete the current entry from db or can keep the entry with payment_status=failed. for future reference.

I hope this will help you

ajithlal left a reply on Session Getting Destroyed After Payment Gateway Redirecting To Success Callback Url.

make 'expire_on_close' => false, and increment the session lifetime and try

ajithlal left a reply on Session Getting Destroyed After Payment Gateway Redirecting To Success Callback Url.

check your session configuration inconfig.session.phpfile

ajithlal started a new conversation Adding Data To Database One Field Doesn't Accepting Value From Request Class

While I'm creating a new entry to my database only one field not accepting value from Request class.

$booking = Booking::create([
                'user_id'              => $request->user_id,
                'event_id'             => $request->event_id,
                'hall_id'              => $request->hall_id,
                'package_id'           => $request->package_id,
            ]);

Here event_id not accepting the value from $request->event_id. When I dd() the $request it having the value. dd($request) output

"user_id" => "1"
"event_id" => "5"
 "hall_id" => "5"
 "package_id" => "1"

What i'm missing?

26 Jul
1 month ago

ajithlal left a reply on SSL Error

check with this .htaccess

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
25 Jul
1 month ago

ajithlal left a reply on Why Is_active On MarkEmailAsVerified() Not Being Saved? (5.8)

probabily is_active type. please check the type

23 Jul
1 month ago

ajithlal left a reply on Call To A Member Function AddEagerConstraints() On Null

please check the foreign key is correct on account_type function

public function account_type(){

        $this->hasOne('App\AccountType', 'f_account_type');

    }

ajithlal left a reply on Routing With Localization In Laravel

update the controller like below and check

public function show(Blog $blog)
{
    return view('blogs.show', compact('blog'));
}

ajithlal left a reply on Call To A Member Function AddEagerConstraints() On Null

This error usually occurs when we are trying to call a function that can be accessed via model and accessing with empty results.

dump your results and check you are calling the method addEagerConstraints() from a null value

ajithlal left a reply on SQL Cannot Add Forign Key

can you check the user table migration and id type. (like: increments or bigIncrements).

if its bigIncrements then change the owner_id field to bigInteger and check

ajithlal left a reply on SQL Cannot Add Forign Key

write the migration like the blow

public function up()
    { 
        Schema::create('projects', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('owner_id')->unsigned();
            $table->string('title');
            $table->text('description');
            $table->timestamps();

       $table->foreign('owner_id')
                  ->references('id')
                  ->on('users')
                  ->onDelete('cascade');
       });
    }

if you have already run the migration then do php artisan migrate:fresh

Note: by running the above command all current tables on db will be dropped.

22 Jul
1 month ago

ajithlal left a reply on Wrong URL

<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName syworkx.public 
     DocumentRoot "C:/xampp/htdocs/syworkx/public/"
     <Directory "C:/xampp/htdocs/syworkx/public/">
         DirectoryIndex index.php
     </Directory>
 </VirtualHost>

can you rewrite it and check?

ajithlal left a reply on The GET Method Is Not Supported For This Route. Supported Methods: POST.

use method post on ajax request and remove datatype from ajax request

ajithlal left a reply on The GET Method Is Not Supported For This Route. Supported Methods: POST.

did you comment the datatype property and check.

ajithlal left a reply on The GET Method Is Not Supported For This Route. Supported Methods: POST.

change the method used in ajax function to post. and comment the data type property.

ajithlal left a reply on Wrong URL

check your virtual host configuration.

25 Jun
2 months ago

ajithlal started a new conversation Session Not Returning The Saved Data On Page Refresh

I'm using session to store some data. I've a session named searchData, that is an array. it is having values

Array ( [Event] => 5 [Hall] => 5 [Date] => 2019-06-25 [Time] => Array ( [0] => Day ) )

I'm trying to add another array of values into the existing array, after adding the values it is returning the new values inside the array like below

[searchData] => Array
                (
                    [event] => 5
                    [hall] => 5
                    [date] => 2019-06-25
                    [time] => Array
                        (
                            [0] => day
                        )

                    [package_id] => 1
                    [price] => 6300
                    [advance] => 3000
                    [selectedPrice] => 3000
                    [add-on] => Array
                        (
                            [5-id] => 5
                            [5-price] => 100.0000
                            [5-count] => 1
                        )

                )

when I refresh the page and print the values in session the newly added array is not showing.

Here is the code used for adding the array of values to existing session.

    $request->session()->put("searchData.add-on.{$addOn->id}-id", $addOn->id);
        $request->session()->put("searchData.add-on.{$addOn->id}-price", $addOn->price);
        $request->session()->put("searchData.add-on.{$addOn->id}-count", $request->count);

in my config/session.php i've changed the below section

'expire_on_close' => true,
21 Jun
2 months ago

ajithlal left a reply on Hello I Want To Upload Image On My Laravel Project , So When I Submit The Request I Get Error Message Under The Image

Sorry your question is not clear. I think you forget to include the enctype on form tag. Please add enctype="multipart/form-data" in your form tag.

Hope this will help.

ajithlal left a reply on How To Get Most Liked Post ID

@DEV0PS -

FeedbackLikes::groupBy('feedback_id')->orderBy('count', 'DESC')->count('*');

Maybe like this

ajithlal left a reply on How To Get Most Liked Post ID

SELECT count(*),feedback_id FROM feedback_likes GROUP BY feedback_id ORDER BY count(*) DESC

Hope this helps

ajithlal left a reply on Form POST Not Working

@NAGRAJ722 - Did you checked your db fie;d length and datatype?

19 Jun
2 months ago

ajithlal left a reply on Intervention Image Not Resizing Image Greater Than 15mb

I've combined both of your( @nash , @deansatch ) suggestion and rewrite my code like below and it works perfect.

$orgFilename = "img-".md5(rand(9999,999999999)).'.'.$request->original_image->getClientOriginalExtension();
            $request->original_image->storePubliclyAs('uploads',$orgFilename);
            
            $destinationPath = public_path('storage/uploads/');
        ini_set('memory_limit', '1000M');
            $img = Image::make($img->getRealPath());
            $img->resize('500', '500')
            ->save($destinationPath.'thumbnail-'.$orgFilename)->destroy();

Thank you @nash and @deansatch for your help.

ajithlal left a reply on Intervention Image Not Resizing Image Greater Than 15mb

@DEANSATCH - Will check with that. No errors are listed in the error log

ajithlal left a reply on Intervention Image Not Resizing Image Greater Than 15mb

@DEANSATCH - this is the code that i'm using for image save

$thumbFilename = "img-" . md5(rand(9999, 999999999)) . '.' . $file->getClientOriginalExtension();
                $file->storeAs('storage/uploads', $thumbFilename);

                $destinationPath = public_path('storage/uploads/');

                $img = Image::make($file->getRealPath());

                $img->resize(500, 500, function ($c) {
                    $c->aspectRatio();
                    // $c->upsize();
                })->save($destinationPath . 'thumb-' . $thumbFilename, 100);

ajithlal left a reply on "Class 'App\Http\Controllers\FetchPostsfromBlog' Not Found"

@DOMEGANG - Please mark the discussion as resolved. This will help others to help some other people they really need help on something.

Thank you

ajithlal left a reply on Undefined Variable

public function getCart()
    {
        $shoppingCart = '';
        $shoppingCart = ShoppingCart::where('user_id', Auth::user()->id)->get();

        if(Auth::check())
        {

            if($shoppingCart->isEmpty())
            {
                $newShoppingCart = new ShoppingCart();
                $newShoppingCart->user_id = Auth::user()->id;
                $newShoppingCart->cart = json_encode($cart);
                $newShoppingCart->save();
            }else{
                $user_id = Auth::user()->id;
                $updateShoppingCart = ShoppingCart::where('user_id', $user_id)->get();

                foreach($updateShoppingCart as $shoppingCart)
                {
                    $shoppingCart->cart = json_encode($cart);
                    $shoppingCart->save();
                }
            }
        }



        return view('public.shopping-cart', [
            'shoppingCart' => $shoppingCart
        ]);

    }

Check this code. I think you are not getting a value from the first line. I mean

$shoppingCart = ShoppingCart::where('user_id', Auth::user()->id)->get();

is not returning anything. Please check with this.