Farhanah

Farhanah

Member Since 3 Weeks Ago

Experience Points
170
Total
Experience

4,830 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 your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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
170 XP
May
31
2 days ago
Activity icon

Replied to Foreach Loop Error

Thank you so much..Its working.spent more than an hour on this.

Activity icon

Started a new Conversation Foreach Loop Error

 </thead>
            <tbody>
            @foreach($campaign as $camp)
            <tr>
              <td>

              <div class="row">
              <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-aqua">
                  <div class="inner">
                    <h3>{{ $camp['campaign_name'] }}</h3>

                    <p>Gift Redemptions today</p>
                  </div>
                  <div class="icon">
                    <i class="ion ion-bag"></i>
                  </div>
                </div>
              </div>
              <div class="page_box">  

                </td>
                <td>test</td>               
            </tr>
            @endforeach
<table class="table search_paginate_selectperpage">
            <thead>
            <tr>
                <th>Campaign</th>
                <!-- <th>Total redemption for today</th> -->
                <th>Summary of stocks redeemed for the day</th>
               
            </tr>
            </thead>
            <tbody>
            <?php $__currentLoopData = $campaign; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $camp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr>
              <td>
 
              <div class="row">
              <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-aqua">
                  <div class="inner">
                    <h3><?php echo e($camp['campaign_name']); ?></h3>
 
                    <p>Gift Redemptions today</p>
                  </div>
                  <div class="icon">
                    <i class="ion ion-bag"></i>

the error says Undefined variable: campaign (0) .But I already defined in the controller.When I dd the varible.the data is there.Plese help me to solve this

public function index(Request $request) {
        $model = new Redemption;
        $count_redemption = $model->count_of_redemption_today();

        $form_param = [
        ];

        $domain = Config::get('globalvariables.gcr_api'); // gcr_api is defined in app/config/globalvariables.php
        $url = $domain . "/api/v1/admin/report/count_redemptions_todays_campaign";

        $HttpReq = new HttpRequest;
        $data = $HttpReq->post($url, $form_param);
        //dd($data);
        return view('admin/home' , [
            'count_redemption' => $count_redemption,
            'campaigns' => $data['campaigns'],
           
        ]);  
    }

Function in controller

Activity icon

Replied to How To Do Sql Query Inside Count Clause

Thank you so much now its working..Used the DB :: raw expression.

May
30
3 days ago
Activity icon

Started a new Conversation How To Do Sql Query Inside Count Clause

public function successful_redemption_count_between_date($start_date, $end_date) {
        $d = DB::select(
            "select `prod`.`product_id` AS `product_id`,`prod`.`product_name` AS `product_name`,
                `op`.`ordered_qty` AS `ordered_qty`, count(`redm`.`campaign_id` WHERE DATE(created_on) = 'CURDATE()') AS `total_redeemed`,count(`redm`.`product_id`) AS `stocks_redeemed`,
                `cam`.`name` AS `campaign_name`, `bk`.`name` AS `bank_name` 
            from `product` `prod` 
                LEFT JOIN `redemption` `redm` on`prod`.`product_id` = `redm`.`product_id`
                JOIN `campaign_product` `cam_prod` on `prod`.`product_id` = `cam_prod`.`product_id`
                JOIN `campaign` `cam` on `cam_prod`.`campaign_id` = `cam`.`campaign_id`
                JOIN `bank` `bk` on `cam`.`bank_id` = `bk`.`bank_id`
                LEFT JOIN 
                (
                    select product_id, sum(quantity) as ordered_qty
                    from ordered_products
                    group by ordered_products.product_id
                ) as op
                    on op.product_id = prod.product_id
            group by `prod`.`product_id`"
        );
             
        return $d;
        
    }

it not working...I want to count amount of redemption for current date.Please help

May
23
1 week ago
Activity icon

Started a new Conversation How To Call The Data From Lumen In Laravel Controller To Check Duplicate Data

I have to make ajax call to check duplicate data.I am very new to this and desperately need help. I think I need to write something similar like this in the laravel controller but how to do that?

if($request->get('email'))
     {
      $email = $request->get('email');
      $data = DB::table("tbl_login")
       ->where('email', $email)
       ->count();
      if($data > 0)
      {
       echo 'not_unique';
      }
      else
      {
       echo 'unique';
      }

The code in the controller in lumen api.

public function check_campaign_title(Request $request) {
      try {
       
        $campaign= Campaign::where([
            ['title', $campaign_name],
            ['bank_id', $campaign_provider],
        ])
        ->count();
    
        $response = array(
            'status' => 'success',
            'message' => 'Successfully fetched name',
            'campaign' => $campaign,
        );
        return response()->json($response);

    } catch(\Exception $e) {
        // When query fails. 
        $response = array(
            'status' => 'failed',
            'message' => 'Failed to fetch name '. $e->getMessage(),
        );

        return response()->json($response);
    }
    }

the code in laravel controller


public function check_campaign_name(Request $request){
        $admin = new Admin_id;
        $admin_user_id = $admin->admin_id();

        $domain = Config::get('globalvariables.gcr_api'); 
        $url = $domain . "/api/v1/campaign/check_title";
        $campaign_title =  $request->input('campaign_title');
        $campaign_provider =  $request->input('campaign_provider');
    
        $form_param = [
            'title' => $campaign_title,
            'bank_id' => $campaign_provider,
        ];
        if ($campaign_title == 'campaign_title' && $campaign_provider =='campaign_provider'){
            $form_param['unique'] = $unique;
        }else{
            $form_param['not_unique'] = $not_unique;

        }

        $HttpReq = new HttpRequest;
        $data = $HttpReq->post($url , $form_param); 
        if ($data['status'] == 'success') {
            return redirect()->back()->with('success_message', $data['message'] )->withInput();

        } else {
            return redirect()->back()->with('fail_message', $data['message'])->withInput();
        }    
    }

My Ajax function


        $(document).ready(function(){
        $('#campaign_title').blur(function(){
        var skudiv2 = '';
        var title = $('#campaign_title').val();
        var bank = $('#campaign_provider').val();
        $.ajax({
        url:"{{ route('campaign.check') }}",
        method:"POST",
        data:{title:title,bank_id:bank_id},
        success:function(result)
        {
            if(result == 'unique')
            {
            $('#skudiv2').html('<label class="text-success">Title Available</label>');
            $('#campaign_title').removeClass('has-error');
            $('#btnCreateCampaign').attr('disabled', false);
            }
            else
            {
            $('#skudiv2').html('<label class="text-danger">Title not Available</label>');
            $('#campaign_title').addClass('has-error');
            $('#btnCreateCampaign').attr('disabled', 'disabled');
            }
        }
        })
        
        });

        });