Maximus1

Maximus1

Member Since 5 Months Ago

Experience Points
400
Total
Experience

4,600 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
0
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.

Level 1
400 XP
Jan
27
4 weeks ago
Activity icon

Started a new Conversation Login - Email Or Membership No In One Field & Wrong Failed Login Response

I have a login field where users either enter their email address or their membershipno. It grants access if any of the credentials(email or membership no) and password are correct and status is active. However, when i use login details with correct membershipno and password but with status not equal to 1, it gives this default error message of " These credentials do not match our records. " instead of " Your account is not active. " This issue only occurs when i use the membershipno instead of email address for login. When i use login details with correct emailaddress and password but with status not equal to 1, it gives the expected error message of " Your account is not active. " What can i do to get the error message of " Your account is not active. " when i use membershipno?

These is the Login Controller

 protected function credentials(Request $request)
        {
          $login = request()->input('email');
          
          //Check whether register_no or email is being used
          $field = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'membershipno';
          return [
             $field => $request->get('email'),
             'password' => $request->get('password'),
             'status' => 1
             ];
        }
    
    /**
     * Get the failed login response instance.
     */
    protected function sendFailedLoginResponse(Request $request)
    {
        $errors = [$this->username() => trans('auth.failed')];
        $user = \App\User::where($this->username(), $request->{$this->username()})->first();
        if ($user && \Hash::check($request->password, $user->password) && $user->status != 1) {
            $errors = [$this->username() => 'Your account is not active.'];
        }
    } 

This is the Login View

<div class="form-group row">
                           <div class="col-md-12">
                               <input id="email" type="text" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" placeholder="{{ _lang('Email / Username') }}" required autofocus>

                               @if ($errors->has('email'))
                                   <span class="invalid-feedback">
                                       <strong>{{ $errors->first('email') }}</strong>
                                   </span>
                               @endif
                           </div>
                       </div>
                       
                       <div class="form-group row">
                           <div class="col-md-12"> 

                               <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" placeholder="{{ _lang('Password') }}" required>

                               @if ($errors->has('password'))
                                   <span class="invalid-feedback">
                                       <strong>{{ $errors->first('password') }}</strong>
                                   </span>
                               @endif
                           </div>
                       </div>  
Oct
25
4 months ago
Activity icon

Replied to How To Switch From TWILIO To GUZZLE For Sending Sms?

This is the revised code.

public function sendsms(Request $request)
private $CMD = 'sendquickmsg';
private $Mail = '[email protected]';
private $SUBACC = 'username';
private $SUBPSS = 'password';
private $sender = 'me';
private $MTYP = 0; 
    {
        $body = $request->input("body");
        
        $client = new Client();
        try
        {
            if($request->input('member_id') != ""){
                if($request->input('member_id') == "all"){
                   foreach( $request->input('members') as $phonenumber ){
                      if( Auth::user()->phone == $phonenumber || $phonenumber == ""){
                          continue;
                      }
                        $response = $client->post('
http://www.smslive247.com/http/index.aspx?', [
                        'verify'    =>  false,
                   'form_params' => [
                       'cmd' => $this->$CMD,
                       'owneremail' => $this->$Mail,
                        'subacct' => $this->$SUBACC,
                        'subacctpwd' => $this->$SUBPSS,
                        'message' => $body,
                        'sender' => $this->$sender,
                        'sendto' => $phonenumber,
                        'msgtype' => $this->$MTYP,
                    ],
                 ]);


                       $response = json_decode($response->getBody(), true);
                    }

                        
                        $log = new MessageLog();
                        $log->receiveby = $phonenumber;
                        $log->message = $body;
                        $log->sender_id = Auth::user()->id;
                        $log->save();
                   }
                }else{
                   return redirect('sms/create')->with('error', _lang('This Is An Illegal Operation'))->withInput();
                   }
                   
                }
            }           
                        
            return redirect()->back()->with('success', _lang('Message was sent sucessfully'));
        
        }  
}

I have tested , it gives no error but still does not send the sms. I think there could be an issue somewhere in the code or I'm I using Guzzle incorrectly

Activity icon

Replied to How To Switch From TWILIO To GUZZLE For Sending Sms?

Okay, let me adjust it and test. Apologies for the mix-up

Activity icon

Replied to How To Switch From TWILIO To GUZZLE For Sending Sms?

Yes I read it and I have changed it to this.....

http://www.smslive247.com/http/index.aspx?cmd=sendquickmsg&owneremail=xxx&subacct=xxx&subacctpwd=xxx&message=xxx&sender=xxx&sendto=xxx&msgtype=0
Activity icon

Replied to How To Switch From TWILIO To GUZZLE For Sending Sms?

I meant that the link I sent works as it is if all parameters are included when placed in a browser.

I want to use it in my send SMS controller via Guzzle but it is not working. How do I make it work with Guzzle?

This is the code again

public function sendsms(Request $request)
    private $USER = 'username';
    private $PASSWORD = 'password';
   
    {
        $body = $request->input("body");
        
        $client = new Client();
        try
        {
            if($request->input('member_id') != ""){
                if($request->input('member_id') == "all"){
                   foreach( $request->input('members') as $phonenumber ){
                      if( Auth::user()->phone == $phonenumber || $phonenumber == ""){
                          continue;
                      }
                        $response = $client->post('http://portal.smsnow.net/api/?', [
                        'verify'    =>  false,
                   'form_params' => [
                        'username' => $this->USER,
                        'password' => $this->PASSWORD,
                        'message' => $body,
                        'sender' => $sender,
                        'phone' => $phonenumber,
                    ],
                 ]);


                       $response = json_decode($response->getBody(), true);
                    }

                        
                        $log = new MessageLog();
                        $log->receiveby = $phonenumber;
                        $log->message = $body;
                        $log->sender_id = Auth::user()->id;
                        $log->save();
                   }
                }else{
                   return redirect('sms/create')->with('error', _lang('This Is An Illegal Operation'))->withInput();
                   }
                   
                }
            }           
                        
            return redirect()->back()->with('success', _lang('Message was sent sucessfully'));
        
        }  
}

Why is Guzzle not sending the sms?

Activity icon

Replied to How To Switch From TWILIO To GUZZLE For Sending Sms?

i dont know what to make of the portal.smsnow anymore... i have switched to this and it works

http://www.smslive247.com/http/index.aspx?cmd=sendquickmsg&owneremail=xxx&subacct=xxx&subacctpwd=xxx&message=xxx&sender=xxx&sendto=xxx&msgtype=0
Activity icon

Replied to How To Switch From TWILIO To GUZZLE For Sending Sms?

This is it

http://portal.smsnow.net/api/?username=$USER&password=$PASSWORD&message=$body&sender=$sender&phone=$phonenumber
Activity icon

Started a new Conversation How To Switch From TWILIO To GUZZLE For Sending Sms?

I need help switching from TWILIO to GUZZLE. I no longer want to use twilio but the sms service i got does not have laravel library like twilio.

Sending sms via twilio works well...See code below :

public function sendsms(Request $request)
    {
        $body = $request->input("body");
        
        $accountSid = get_option("TWILIO_SID");
        $authToken  = get_option("TWILIO_TOKEN");
        $mobileNumber = get_option("TWILIO_MOBILE");
        $client = new Client($accountSid, $authToken);
        try
        {
            if($request->input('member_id') != ""){
                if($request->input('member_id') == "all"){
                   foreach( $request->input('members') as $phonenumber ){
                      if( Auth::user()->phone == $phonenumber || $phonenumber == ""){
                          continue;
                      }
                        $client->messages->create(
                            $phonenumber,
                            array(
                                 'from' => $sender,
                                 'body' => $body
                             )
                        );
                        
                        $log = new MessageLog();
                        $log->receivedby = $phonenumber;
                        $log->message = $body;
                        $log->sender_id = Auth::user()->id;
                        $log->save();
                   }
                }else{
                   return redirect('sms/create')->with('error', _lang('This Is An Illegal Operation'))->withInput();
                   }
                   
                }
            }           
                        
            return redirect()->back()->with('success', _lang('Message was sent sucessfully'));
        
        }  
}

My attempt to use another sms service via Guzzle does not work.... See code below:

public function sendsms(Request $request)
    private $USER = 'username';
    private $PASSWORD = 'password';
   
    {
        $body = $request->input("body");
        
        $client = new Client();
        try
        {
            if($request->input('member_id') != ""){
                if($request->input('member_id') == "all"){
                   foreach( $request->input('members') as $phonenumber ){
                      if( Auth::user()->phone == $phonenumber || $phonenumber == ""){
                          continue;
                      }
                        $response = $client->post('http://portal.smsnow.net/api/?', [
                        'verify'    =>  false,
                   'form_params' => [
                        'username' => $this->USER,
                        'password' => $this->PASSWORD,
                        'message' => $body,
                        'sender' => $sender,
                        'phone' => $phonenumber,
                    ],
                 ]);


                       $response = json_decode($response->getBody(), true);
                    }

                        
                        $log = new MessageLog();
                        $log->receiveby = $phonenumber;
                        $log->message = $body;
                        $log->sender_id = Auth::user()->id;
                        $log->save();
                   }
                }else{
                   return redirect('sms/create')->with('error', _lang('This Is An Illegal Operation'))->withInput();
                   }
                   
                }
            }           
                        
            return redirect()->back()->with('success', _lang('Message was sent sucessfully'));
        
        }  
}

Why is Guzzle not sending the sms?

Oct
01
4 months ago
Activity icon

Replied to How To Block Duplication Of Entries?

Perfect answer @bobbybouwmann . It worked!!! Thank you

Activity icon

Replied to How To Get Route Url Id

@himanshurajvanshi your solution did not work.

public function store(Request $request,$route_id)
    {
        $homeworkanswer = new \App\HomeworkAnswer();
        $homeworkanswer->date = $request->date;
        $homeworkanswer->student_id = get_studentid();
        $homeworkanswer->homework_id = $route_id;
        $homeworkanswer->myanswer = $request->myanswer;
        
        
        $homeworkanswer->save();

it gave this error - "Too few arguments to function App\Http\Controllers\Users\StudentController::store_assignmentanswer(), 1 passed and exactly 2 expected"

Activity icon

Replied to How To Get Route Url Id

Thank you siangboon but you did not address my question properly. First, i do not want an input name "route_id". I know how to do this if i want to but i want the route id from the url ---http://127.0.0.1/my_homework/add_answer/9.....I want to do this right in the controller. The id here for example is 9. I want it stored as homework_id when saving my homework as a student automatically.

Please note that the route_id is same as homework_id. The student answers are stored in an homeworkanswers table which as homework_id as a column as you can see here in the controller :

public function store(Request $request)
    {
        $homeworkanswer = new \App\HomeworkAnswer();
        $homeworkanswer->date = $request->date;
        $homeworkanswer->student_id = get_studentid();
        $homeworkanswer->homework_id = $request->route_id;
        $homeworkanswer->myanswer = $request->myanswer;
        
        
        $homeworkanswer->save();
Sep
30
4 months ago
Activity icon

Started a new Conversation How To Block Duplication Of Entries?

How can i avoid duplication of homework answers. See my controller below. I only want students to post an answer for a specific homework just once. Which means after posting, they will be blocked from adding another answer. How can i achieve this?

public function create_homeworkanswer($id){
         //  
           }
public function store(Request $request)
    {
        $homeworkanswer = new \App\HomeworkAnswer();
        $homeworkanswer->date = $request->date;
        $homeworkanswer->student_id = get_studentid();
        $homeworkanswer->homework_id = $request->route_id;
        $homeworkanswer->myanswer = $request->myanswer;
        
        
        $homeworkanswer->save();

This is the route :

Route::get('my_homework/create/{id}', 'Users\[email protected]_homeworkanswer');
Route::post('my_homework/store', 'Users\[email protected]');
Activity icon

Started a new Conversation How To Get Route Url Id

I need help getting the url id so as to use it for storage in a new table as homework id.

public function store(Request $request)
    {
        $homeworkanswer = new \App\HomeworkAnswer();
        $homeworkanswer->date = $request->date;
        $homeworkanswer->student_id = get_studentid();
        $homeworkanswer->homework_id = $request->route_id;
        $homeworkanswer->myanswer = $request->myanswer;
        
        
        $homeworkanswer->save();

This is the route :

Route::post('my_homework/store', 'Users\[email protected]');

So when i am saving, it should automatically save the url id as homework id :

$homeworkanswer->homework_id = $request->route_id;

My method above returns nothing, how can i make it work?

Sep
15
5 months ago
Activity icon

Replied to How To Get A Value Based On A Selected Variable In An Array

Can anyone please help resolve this issue?

Sep
12
5 months ago
Activity icon

Replied to How To Get A Value Based On A Selected Variable In An Array

Now , i believe the issue is how to get the priceamount from the fee_type[] array.

The priceamount field will be diabled or read-only because it displays based on the feetype selected. When i tried inputting the priceamount manually, it saved ok without errors but i dont want users to have this control.

The solution will be how to get the priceamount from the fee_type[] array.

I dont know if i have to adjust something here :

<script type="text/javascript">
$('select[name=fee_type]').on('change',function(){
            var _token=$('input[name=_token]').val();
            var fee_id = $('select[name=fee_type]').val();
            $.ajax({
                type: "POST",
                url: "{{url('prices/fee_amount')}}",
                data:{_token:_token,fee_id:fee_id},
                success: function(data){
                    $('input[name=priceamount]').val(data);             
                }
            });
        }); 
</script>

OR here :

public function get_fee_amount(Request $request)
                              {
                           $feetype = FeeType::find($request->fee_id)->priceamount;
                           return $feetype;
                              }
Activity icon

Replied to How To Get A Value Based On A Selected Variable In An Array

Thank you Snapey . It shows the amount now. It worked only when i also changed priceamount[] to priceamount but it wont save when i submit.

I get this error "Invalid argument supplied for foreach()"

This is the store section of the controller :

 public function store(Request $request)
    {
        $validator = Validator::make($request->all(), [
            //
        ]);     
        
                
                //Store Price Item
                $counter = 0;
                foreach($request->input("fee_type") as $fee_id){
                    if($request->input("priceamount")[$counter] == 0 && $fee_id==""){
                        continue;
                    }
                    $priceItem = new PriceItem();
                    $priceItem->price_id = $price->id;
                    $priceItem->fee_id = $fee_id;
                    $priceItem->quantity = $request->input("quantity")[$counter];
                    $priceItem->priceamount = $request->input("priceamount")[$counter];
                    $priceItem->save();
                    
                    $counter++;
                }
            }
        

The error in on this line :

foreach($request->input("fee_type") as $fee_id){
Activity icon

Replied to How To Get A Value Based On A Selected Variable In An Array

Can you please look into code? Any solutions?

Activity icon

Started a new Conversation How To Get A Value Based On A Selected Variable In An Array

I want to get and display the corresponding value of a selected variable in an array. I think did okay with the code but it is bringing no result. This value should be inputed automatically in the priceamount field when the corresponding fee type is selected.

BLADE-VIEW

<div>
<td width="40%"><select name="fee_type[]" class="form-control select2" required>
                    <option value="">{{_lang('Select One') }}</option>
                    {{ create_option('fee_types','id','fee_type',old('fee_id')) }}
                </select></td>                  
                    <td><input type="text" class="form-control float-field priceamount" name="priceamount[]"value="0" required></td>
</div>

<script type="text/javascript">
$('select[name=fee_type]').on('change',function(){
            var _token=$('input[name=_token]').val();
            var fee_id = $('select[name=fee_type]').val();
            $.ajax({
                type: "POST",
                url: "{{url('prices/fee_amount')}}",
                data:{_token:_token,fee_id:fee_id},
                success: function(data){
                    $('input[name=priceamount]').val(data);             
                }
            });
        }); 
</script>

CONTROLLER

 public function get_fee_amount(Request $request)
                              {
                           $feetype = FeeType::find($request->fee_id)->priceamount;
                           return $feetype;
                               }    

Now i am trying to get the corresponding priceamount from the fee_type selected but without success. It still does not show or get the priceamount value. Can anyone please help?