Reprogammer

Member Since 9 Months Ago

Experience Points
810
Total
Experience

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

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 1
810 XP
May
08
1 day ago
Activity icon

Started a new Conversation Query Builder: How To Select Rows Based On A Given Time Range.

I want to select rows that have been created for the past 5 minutes, although, I am not quite sure how to approach this.

This is how it looks like in MySQL


SELECT * FROM (SELECT * FROM transactions
	WHERE TIMEDIFF(timeIn, timeOut)>='-00:00:01'
		AND TIMEDIFF(timeIn, timeOut)<='-00:05:00'
		AND dateIn=DATE(NOW())) sub ORDER BY user_id
May
06
3 days ago
Activity icon

Started a new Conversation TIMEDIFF() In Laravel

I am trying to find the difference between two DateTime type columns in minutes using Laravel's query builder. I am aware of PHP's TIMEDIFF() function, however, Laravel doesn't seem to have such a function. Any ideas to replicate TIMEDIFF() in Laravel or maybe I missed it in the documentation.

Activity icon

Started a new Conversation Lodash _.throttle Not Working

I'm trying to use Lodash throttle to control how many times my AJAX will run, however, it doesn't seem to work. I don't know if my syntax is wrong or something. I'm grateful for any suggestion.

here is my AJAX

function ajaxThrot(){

                $.ajax({
                    url:"{{ route('id.scanner') }}",
                    type:'POST',
                    datatype: 'json',
                    data:{idNumber:idNumber,
                        _token: '{{csrf_token()}}'
                            },
                            
                    success:function(res){                  
                        alert(res);
                    }      
                });

                }

                function testThrottle(){
                _.throttle(ajaxThrot(), 5000);
            }

            testThrottle();
May
04
5 days ago
Activity icon

Started a new Conversation Lodash Functions Not Working.

I downloaded the script and implemented it in my projects public/js directory

I tested it with the following code, however, nothing is popping out of my console.

const menuItems = [
    'A', 'B', 'C', 'D', 'E', 'F',
  ]
  
  const newMenu = _.chunk(menuItems, 3)

  console.log(newMenu)

I added the lodash.js file like so

<script src="{{ asset('/js/lodash.js') }}"></script>
Apr
30
1 week ago
Activity icon

Replied to AJAX Sending Multiple Requests At Once.

Thanks for the help. I'll give it a go.

Activity icon

Started a new Conversation AJAX Sending Multiple Requests At Once.

I have this project wherein I'm making a barcode scanner with Quagga.js for IDs using a laptop's, or a phone's camera, the thing is it keeps scanning multiple times the longer the scanner is focused on the barcode thus sending multiple requests to the Laravel controller. I need it to scan once. Any help is appreciated. Thanks!

My JavaScript

<script>
        Quagga.init({
            inputStream: {
                name: "Live",
                type: "LiveStream",
                target: document.querySelector('#camera')    // Or '#yourElement' (optional)
            },
            decoder: {
                readers: ["code_39_reader"]
            }
        }, function (err) {
            if (err) {
                console.log(err);
                return
            }
            console.log("Initialization finished. Ready to start");
            Quagga.start();
        });

        Quagga.onDetected(function (data) {
            
            console.log(data.codeResult.code);
            document.querySelector('#results').innerText = data.codeResult.code;
            
            var idNumber = data.codeResult.code;
            
            $.ajax({
                    url:"{{ route('scanID2') }}",
                    type:'POST',
                    datatype: 'json',
                    data:{idNumber:idNumber,
                         _token: '{{csrf_token()}}'
                            },
                            
                    success:function(res){                  
                        var tableRow='';

                        $('#dynamic-row').html('');

                        $.each(res, function(index, value){
                            tableRow = '<tr><td>'+value.id+'</td><td>'+value.userType+'</td><td>'+value.fname+'</td><td>'+value.lname+'</td></tr>';

                            $('#dynamic-row').append(tableRow);
                        });
                    }      
                });
        });
        
    </script>
Apr
27
1 week ago
Activity icon

Replied to AJAX POST 500 Internal Server Error

Figured it out! I didn't declare "use DB;" in my controller. Anyways, thanks for the response. Cheers!

Activity icon

Replied to AJAX POST 500 Internal Server Error

this is what I came up with

Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute
Activity icon

Started a new Conversation AJAX POST 500 Internal Server Error

I'm creating a live search function for my project. However, I keep encountering POST 500 Internal Server Error.

Here is my AJAX

$('body').on('keyup','#search-posts',function(){
        var searchQuest = $(this).val();

        $.ajax({
            url: "{{ route('livesearch')}}",
            type: "POST",
            dataType: "json",
            data: {searchQuest: searchQuest,
                    _token: '{{csrf_token()}}'
            },
            success: function(data){
                var tableRow = '';

                $('#dynamic-row').html('');

                $.each(res, function(index, value){
                    tableRow = '<tr><td>'+ value.id +'</td><td>'+ value.user_id +'</td><td>'+ value.timeIn +'</td><td>'+ value.timeOut +'</td><td>'+ value.date +'</td><td></td></tr>';

                    $('#dynamic-row').append(tableRow);
                });
            }
        });
    });

and my Controller

$keyword = $request->get('searchQuest');
        
        $transactions = DB::table('transactions')
                        ->where('user_id', 'LIKE', '%'.$keyword.'%')
                        ->orWhere('timeIn', 'LIKE', '%'.$keyword.'%')
                        ->orWhere('entrance', 'LIKE', '%'.$keyword.'%')
                        ->orWhere('date', 'LIKE', '%'.$keyword.'%')
                        ->orWhere('timeOut', 'LIKE', '%'.$keyword.'%')
                        ->orWhere('exit', 'LIKE', '%'.$keyword.'%')
                        ->orderBy('user_id', 'desc')
                        ->get();
                        return Response::json($transactions);

I appreciate any help I can get. Thanks!

Apr
22
2 weeks ago
Activity icon

Replied to How Do I Display JSON Response Returned By Laravel Controller?

I'm trying to display the json contents into a div tag.

About the POST tag, my controller has other codes in it but I just posted what I thought is relevant.

I'll give this a try. Cheers!

Activity icon

Started a new Conversation How Do I Display JSON Response Returned By Laravel Controller?

I'd appreciate any help. Thanks!

Here is my controller

$users = \DB::table('users')
                    ->select(\DB::raw('id', 'userType', 'username', 'fname', 'lname', 'contactNo'))
                    ->where('id', '=', $id)
                    ->get();

return Response::json($users);

$.ajax({
                    url:"{{ route('users.create') }}",
                    type:'POST',
                    datatype: "json",
                    data:{id:id,
                             _token: '{{csrf_token()}}'
                            },
                    success:function(data){
                        console.log(data);

                        
                    }
                        
                    });
Apr
21
2 weeks ago
Activity icon

Replied to AJAX POST - 500 (Internal Server Error)

How could I have missed that. Cheers mate!

Activity icon

Started a new Conversation AJAX POST - 500 (Internal Server Error)

I have a project wherein if I scan a user's barcode the user is logged in to the database. All components are working for the scanner part but when a barcode is scanned I keep getting the 500-Internal Server Error. Now, I know that this error pops up under different circumstances but if you find something wrong in my code, I'd appreciate any help.

My AJAX

Quagga.onDetected(function (data) {
            console.log(data.codeResult.code);
            document.querySelector('#results').innerText = data.codeResult.code;
            

            var idNumber1 = data.codeResult.code;

            $.ajax({
                    url:"{{ route('scanID2') }}",
                    type:'POST',
                    datatype: "json",
                    data:{idNumber1:idNumber1,
                             _token: '{{csrf_token()}}'
                            },
                    success:function(data){
                        console.log(data);
                    }
                    });
        });

My Controller-Method

public function scan2(Request $request)
    {

        $id1= $request->get('idNumber');


        if (DB::table('users')->where('id', $id1)->exists()) {
            
            $users = \DB::table('users')
                    ->select(\DB::raw('id', 'userType', 'username', 'fname', 'lname', 'contactNo'))
                    ->where('id', '=', $id1)
                    ->get();

            //CREATING TRANSACTION FOR SCANNED USER WHEN LOGGING IN IF NO CURRENT DATA EXISTS
            if(DB::table('transactions')
                    ->where('user_id', $id1)
                    ->where('date', Carbon::today()->toDateString())
                    ->whereNotNull('timeIn')
                    ->whereNull('timeOut')
                    ->doesntExist()){

                foreach($users as $user){
                    $details = [
                            [
                                'user_id' => $id1,
                                'timeIn' => Carbon::now(),
                                'date' => Carbon::today(),
                                'entrance' => Auth::user()->post,
                            ]
                        ];

                        DB::table('transactions')->insert($details);

                }
            }else if(DB::table('transactions')
                            ->where('user_id', $id1)
                            ->whereNotNull('timeIn')
                            ->where('date', Carbon::today()->toDateString())
                            ->whereNull('timeOut')
                            ->exists()){

                                
                                
                //UPDATE TRANSACTIONS TABLE WHEN SCANNING OUT
                $data1 = \DB::table('transactions')
                    ->select('*')
                    ->where('user_id', $id1)
                    ->where('date', Carbon::today()->toDateString())
                    ->whereNotNull('timeIn')
                    ->whereNull('timeout')
                    ->get();

                foreach($data1 as $data2){
                    \DB::table('transactions')
                        ->where('user_id', '=', $id1)
                        ->whereNotNull('timeIn')
                        ->whereNull('timeout')
                        ->update(['timeOut' => Carbon::now(),
                                'exit' => Auth::user()->post]);
                }

                
            }else{
                return redirect()->route('securityOfficeHome')
                ->with('success', 'There is something wrong.');
            }
            
            return redirect()->route('securityOfficeHome')
                ->with('success', 'User logged in.');

        } else {
            $response = Http::get('http://127.0.0.1:808/api/scanUsers/'.$id1.'/authenticate');
            
            $data = json_decode($response,true);
            
            if ($data["data"] === False) {
                 
                return redirect()->route('securityOfficeHome')
                ->with('danger', 'User ID does not exist.');

            } else {
                
                foreach($data as $data1){
                    DB::table('users')->insert(
                        array('id' => $data1['id'],
                                'userType' => $data1['userType'],
                                'fname' => $data1['fname'],
                                'lname' => $data1['lname'],
                                'email' => $data1['email'],
                                'contactNo' => $data1['contactNo'],
                                'address' => $data1['address'],
                                'password' => $data1['password'],
                                'status' => $data1['status'],
                                'activity' => $data1['activity'],)
                    );

                    foreach($data as $data1){
                        DB::table('users')->insert(
                            array(  'user_id' => $data1['id'],
                                    'timeIn' => Carbon::now(),
                                    'date' => Carbon::today(),
                                    'entrance' => Auth::user()->post)
                        );
                    }

                    

            return route('securityOfficeHome');
                }

            }

                   

        return view('securityoffice.index');
        }

    }
Apr
17
3 weeks ago
Activity icon

Started a new Conversation Unknown Named Parameters, Laravel 8

I recently updated from Laravel 7>8, but my project is using the 7 version. Every now and then I encounter this error "Unknown named parameter" every time I open routes that have/require parameters. I am pretty sure it's because of the update but I do not know how to fix it...

Mar
23
1 month ago
Activity icon

Replied to Barcode Reader On Web Apps

thanks! I'll give it a try. CHEERS!

Activity icon

Started a new Conversation Barcode Reader On Web Apps

I have a web app project wherein I need to add a barcode reader for it's mobile version (not an Android or iOS app). Can anybody suggest any barcode reader packages or any third party apps I can use.

Jan
11
3 months ago
Activity icon

Replied to Can Laravel API Endpoints Have Parameters?

yep, i changed it.

Activity icon

Replied to Can Laravel API Endpoints Have Parameters?

it works. thanks mate.

Activity icon

Replied to Can Laravel API Endpoints Have Parameters?

Cheers mate. Thanks a lot.

Activity icon

Replied to Can Laravel API Endpoints Have Parameters?

$response = Http::get('http://example.com/users', [ 'name' => 'Taylor', 'page' => 1, ]);

is this it?

Activity icon

Started a new Conversation Can Laravel API Endpoints Have Parameters?

I'm trying to create an endpoint that allows the client to request for an authorization to the server by sending his/her ID along with the API request. Is this possible?

Nov
23
5 months ago
Activity icon

Started a new Conversation How Do I Configure A Second Database In Laravel?

My aim is to pass data from both databases