ajithlal

ajithlal

Member Since 5 Months Ago

Web developer at Ernakulam

Experience Points 10,510
Experience Level 3

4,490 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 4
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.

25 Jun
3 weeks 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
3 weeks 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 - ```php 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
4 weeks 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(1000, 1000, 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.

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

@deansatch when I comment the save function using Intervention, it works fine. when using the intervention it is returning 500.

ajithlal left a reply on Undefined Variable

@bastet did you getting the error inside the above given code or in view?

ajithlal left a reply on Undefined Variable

return view('public.shopping-cart', compact('shoppingCart'));

try this

ajithlal started a new conversation Intervention Image Not Resizing Image Greater Than 15mb

Hi All,

I'm using Intervention\Image\Facades\Image to resize image. It works fine when uploading images upto 12Mb. but it is returning 500 while uploading image greater than 20Mb.

Here is my php.ini settings

max_execution_time = 1000 max_input_time = 1000 memory_limit = 1000M post_max_size = 1000M upload_max_filesize = 1000M

30 Apr
2 months ago

ajithlal left a reply on Insert Multiple Records Into Multiple Tables

try ```php $measurement['weight']

08 Mar
4 months ago

ajithlal left a reply on Count(): Parameter Must Be An Array Or An Object That Implements Countable

@SNAPEY - I said the same thing and he responded that is not the error.

Please check the redirection after the soft deletion. I think that will be the issue.

There is nothing wrong with the back();

There is something wrong these:

Products::where('prod_id', $product->prod_id)->delete(); Wishlists::where('prod_id', $product->prod_id)->delete();

ajithlal left a reply on Laravel

check the variable companies passed from controller or defined in the view

ajithlal left a reply on Find Out Days Between Two Dates

$date = Carbon::parse('2016-09-17 11:00:00');
$now = Carbon::now();

$diff = $date->diffInDays($now);

This one too

ajithlal left a reply on Struggling With Rule In A Request File

hope required_if rule will help you out. Eg:

return [
      'has_login' => 'sometimes',
      'pin'       => 'required_if:has_login,on',
];

ajithlal left a reply on Count(): Parameter Must Be An Array Or An Object That Implements Countable

Please check the redirection after the soft deletion. I think that will be the issue.

07 Mar
4 months ago

ajithlal left a reply on How I Get Only Day-mounth From Date

If the $results->start_date and $results->end_date are timestamps then, you can simple use php date() function like below

date('d-M', $results->start_date);

and

date('d-M', $results->end_date);
06 Mar
4 months ago

ajithlal left a reply on 400 Bad Request In Method DELETE And PATCH

Set the method to POST and pass _method as data. See the below example

$ajax({
    method: POST,
    url: $(this).prop('action'),
    data: { testData: 'this is a test' , '_method':'PUT'},
    headers: { 'X-CSRF-TOKEN': token },
    success: function(data, textStatus, jqXHR) {
        console.log(data);    // prints out the data
    }
}); 

Hope this will help you out.

ajithlal left a reply on Middleware Apply For This Page

@VANDAN - are you registered your middleware? If not please refer the link

https://laravel.com/docs/5.7/middleware#registering-middleware

ajithlal left a reply on Middleware Apply For This Page

@VANDAN - are you using a custom middleware?

ajithlal left a reply on Middleware Apply For This Page

@RONNY11 - this links are not satisfying @vandan s requirements. then what is the purpose if this link brother?

ajithlal left a reply on Middleware Apply For This Page

If you want to add a middleware for this controller then,

class TrainingController extends Controller

{
    public function __construt()
    {
        $this->middleware('middleware_name');
    }
    
    //your functions
}

replace "middleware_name" with actual middleware name.

Hope this will works

ajithlal left a reply on Button On The Same Line / Row

@AIN - I feel sorry for the error. Please put the add button on out of the loop and check

05 Mar
4 months ago

ajithlal left a reply on Button On The Same Line / Row

<button title='Add Author' type="button" name="add" id="add" class="btn btn-primary ">Add Group Member</button>
                
        @if($i > 0)
        <div class="col-lg-4">
                                <button title="Remove Field" type="button" name="remove" id="{{$i}}" class="btn btn_remove btn-danger">Remove Group Member</button>
        </div>

                        @endif
                    </div>

                    <div class="col-lg-4">
                        <div class="form-group">
                            {!! Form::label('group_member['.$i.'][name]', 'Name :') !!}
                            {!! Form::text('group_member['.$i.'][name]', $member->name , ['class' => 'form-control', 'placeholder' => 'Name']) !!}
                        </div>
                    </div>

                    <div class="col-lg-4">
                        <div class="form-group">
                            {!! Form::label('group_member['.$i.'][affiliation]', 'Affiliation :') !!}
                            {!! Form::text('group_member['.$i.'][affiliation]',$member->affiliation , ['class' => 'form-control', 'placeholder' => 'Affiliation']) !!}
                        </div>
                    </div>

Please re write the code like above. This will add the remove button after the affiliation field.

ajithlal left a reply on How To Post Full Coding Here Without Being Cut?

Image upload is not supported, but it does support linking to images.

![Voyager](https://devdojo.com/media/images/September2017/voyager-academy-wallpaper-medium.jpg?fm=jpg&q=70&s=b9453bc27cc03f497259d90c5a03fe3d)

ajithlal left a reply on How To Only Submit Password When Typed

use different rules

class UserModel {
        public static $register_rules = [ 'rules' => 'requred' ];
        
        public static $update_rules = [ 'rules' => 'requred' ];

}

and then

Validator::make($data, UserModel::$register_rules);

Validator::make($data, UserModel::$update_rules);

This method can be used in every validation way you choose.

With Controller, with $this->validate() or Validator::make

if you are not validating the data then manually check the password is empty or not. If the password field is empty then use the old password value from the database.

ajithlal left a reply on Button On The Same Line / Row

Hi @ain ,

When I put your code in my view page the buttons are displaying on the same row same position. Can you pls explain the actual requirement?

Thanks, Ajith

01 Mar
4 months ago

ajithlal left a reply on Set Non Expired Session In Laravel 5.7

@HUSSEIN_DERBALAH - If you got the answer for this question, please pic the answer and mark this thread as completed.

Thanks, Ajith

28 Feb
4 months ago

ajithlal left a reply on "Argument 1 Passed To Illuminate\Database\Grammar::parameterize() Must Be Of The Type Array, Null Given, Called In E:\LaravelProject\metrofeedback_v1\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php On Line 853

public function store(Request $request)
    {
        $input = $request->all();

        $category = new AddCategory();
        $category->c_date = $input['c_date'];
        $category->c_name = $input['c_name'];
        $category->c_desc = $input['c_desc'];

        $subcategory = new AddSubCategory();
        $subcategory->sc_name = $input['sc_name'];
        $subcategory->sc_desc = $input['sc_desc'];
        $subcategory->cat_id = $category->id;
     
        $category->save();
        $subcategory->save();
}
27 Feb
4 months ago

ajithlal left a reply on When I Download Project From GIT And Used In Local I Got Following Error?

I think your project missing some file. try git pull or clone the project once again. check the cloning is successful and run composer install on the fresh project

ajithlal left a reply on When I Download Project From GIT And Used In Local I Got Following Error?

This error is occurred due to the composer dependency not completely added. Is the composer install is successfull?

ajithlal left a reply on Undefined Variable Only Showing Online Server, But On Localhost Works Good

Make sure your .env.example file contains the following

APP_ENV=local
APP_DEBUG=true

Later rename file .env.example to .env

This should fix the problem.

Maybe try to stop your server and restart it.

Sometimes that solves the issue debugger not working.

ajithlal left a reply on Undefined Variable Only Showing Online Server, But On Localhost Works Good

@LYIUB - set APP_DEBUG=true on the .env file on live server. you can see the error.

ajithlal left a reply on Undefined Variable Only Showing Online Server, But On Localhost Works Good

The $user_role variable will difined only if $role_permisssions have values. if the $role_permissions is return empty, then the $user_role will not defined. define user role as empty at the start of the function or outside the if statement.

$user_role = ''; 
 $role_permissions = DB::table('role_user')
            ->where('user_id', '=', $user_id)
            ->get();


        foreach ($role_permissions as $role) {
            $user_role = $role->role_id;
        }

        if ($user_role == 1) {
            $user_status = 'Admin';
        } else {
            $user_status = 'User';
        }

you are not getting error on localhost because your role_user table having values satisfying the condition and your live database doesn't.

please check the database having values. Also try the above mentioned code

ajithlal left a reply on Set Non Expired Session In Laravel 5.7

You can use cookie insted

ajithlal left a reply on When I Download Project From GIT And Used In Local I Got Following Error?

Remove the composer.lock and vendor folder and run

composer install
26 Feb
4 months ago

ajithlal left a reply on What Does It Mean Undefined Offset: 1

Jist print the array $sizeIDArr (print_r($sizrIDArr); and check if there is an index 1 is there.

Print_r() will return an indexed array having [0]=>somevalue,[1]=>somevalue.

Some times the index 1 vill not be in the array.

ajithlal left a reply on Nothing To Migrate

@EGGHEAD77 - When we install create new laravel peoject there will be two migration files for users table ans password_reset I think. Accidently you deleted the file.

php artisan migrate

Command is used to run the migration. It will rum the new migration that wll be listed inside database/migration folder.

php artisan make:migrate <migration_name> 

Command will helps to create new migration inside database/migration folder.

Please note that the

php artisan make:migrate

Command will only generate the migration file with structure only. You have to manually specify the fields inside the migration.

For now if the database/migrations folder is empty, then download the files listed here (https://github.com/laravel/laravel/tree/master/database/migrations) and paste the files inside your local project ->database->migration folder and run

php artisan migrate

Then you can see two tables with columns on your database.

Continue the tutorial... :)

ajithlal left a reply on Nothing To Migrate

could you please check the migration folder inside database folder for migrations

ajithlal left a reply on Global Variable In Laravel

@PHOENIX5 - Hope this will helps

class SampleController extends Controller
{
    public $id;

    public function __construct()
    {
        if (empty($this->id)
    {
        $this->id = Str::random();
    }
    }

    public function someFunction()
    {
        dd($this->id);
    }
}
25 Feb
4 months ago

ajithlal left a reply on Resource Controller Destroy Method

Check your where condition. Not $categorie its $categorie_name.