PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 24, 2022

[FIXED] ErrorException : Undefined variable: days

 January 24, 2022     eloquent, laravel, laravel-5, php, sql     No comments   

Issue

UsermailRespoitory

I want the days should be added inside addDays() The days i will get frm my database

public function create() 
    {

        $users = User::where('user_type', 2)->get();
        $auto_email_templates=AutoEmailTemplate::all()->pluck('days');


        foreach ($users as $user) {

           if( $user->created_at > Carbon::now()->addDays($days)){
                if ($user->created_at < Carbon::now()) //signup
                {    
                    return false;
                }
                    Mail::to($user)->send(new Automail($template));
                    return true;

           }
}

Solution

  public function create() 
    {

        $users = User::where('user_type', 2)->get();
        $auto_email_templates=AutoEmailTemplate::all();


        foreach ($users as $user) {
            foreach($auto_email_templates as $mail){

                if( $user->created_at > Carbon::now()->addDays($mail->days)){
                        if ($user->created_at < Carbon::now()) //signup
                        {    
                            return false;
                        }
                            Mail::to($user)->send(new Automail($template));
                            return true;

                }


Answered By - Navanitha Moorthy
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing