joshblevins

joshblevins

Member Since 8 Months Ago

Experience Points 4,390
Experience Level 1

610 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 22
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

18 Mar
2 days ago

joshblevins left a reply on Query Relationship Returns Wrong Values

@STAUDENMEIR - Awesome I will take a look at it again, it may be me but when I read through it, it may have processed my brain backwards.

joshblevins left a reply on Query Relationship Returns Wrong Values

@STAUDENMEIR - Yes I only want to see those employees who have a performance_rating < 80

joshblevins left a reply on Query Relationship Returns Wrong Values

@STAUDENMEIR - Only when less than (<) 80

joshblevins left a reply on Query Relationship Returns Wrong Values

@STAUDENMEIR - correct it is a one to many relationship

joshblevins left a reply on Query Relationship Returns Wrong Values

@STAUDENMEIR - It is a graded scale 0-100 So some employees may have a performance_rating < 80 however most will be greater than 80

joshblevins left a reply on Query Relationship Returns Wrong Values

@STAUDENMEIR - If I am trying to locate employees with evals < 80 wouldn't I want to check if any of the employees match the constraint of do any employees exist that have an eval less than 80%.

joshblevins started a new conversation Query Relationship Returns Wrong Values

I am searching through my employee DB attempting to locate entries where the drivers evaluation is less than 80.

The return I get with below code is employees with driver evaluations greater than 80.

$signatures = Employee::whereHas('driver_eval', 
        function($q) 
        {
            $q->where('performance_rating', '<', '80');
            
        })
        ->whereIn('primary_station', [$sarray])->get();
17 Mar
3 days ago

joshblevins left a reply on Signature Pad With Ajax

For anyone else who may be trying to accomplish the same here is the end product. form

 <form  method="post" enctype="multipart/form-data" class="ansform"> <!--Panel-->

                    {{ csrf_field() }}
                    <div class="wrapper">

                        <canvas id="signature-pad" class="signature-pad" width=400 height=200></canvas>
                    </div>
                    <div>
                        <input type="hidden" name="assid" value="{{$da->id}}">
                        <button id="save">Save</button>
                        <button id="clear">Clear</button>
                    </div>
                    <!--/.Panel-->
                </form>

js / AJAXX

$(function () {

            $.ajaxSetup({
  headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }
});

            var signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
              backgroundColor: 'rgba(255, 255, 255, 0)',
              penColor: 'rgb(0, 0, 0)'
            });
            var saveButton = document.getElementById('save');
            var cancelButton = document.getElementById('clear');
            var assid = document.getElementById('assid').value;

            cancelButton.addEventListener('click', function (event){
                event.preventDefault();
            });
            
            saveButton.addEventListener('click', function (event) {

                 event.preventDefault();
                 
                if (signaturePad.isEmpty()) {
                    sweetAlert("Oops...", "Please provide signature first.", "error");
                } else {

                    // do ajax to post it
                    $.ajax({
                        url : '{{route('driving.signature')}}',
                        type: 'POST',
                        data : {
                            signature: signaturePad.toDataURL(),
                            assid: assid,
                            
                        },
                        success: function(response)
                        {
                           
                            console.log(response);
                        },
                        error: function(response)
                        {
                            
                            console.log(response);
                        }
                    });
                }

            });

            cancelButton.addEventListener('click', function (event) {
                signaturePad.clear();
            });

        });

controller

    /* *
     * Save Signature
     *
     * @param Request $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function saveSignature(Request $request)
    {
        //Find Assessment in DB//
        $signature = DrivingAssessments::find($request->assid);
       
        //Get image from ajax, encode then decode the image to store//
        $data_uri = $request->signature;
        $encoded_image = explode(",", $data_uri)[1];
        $decoded_image = base64_decode($encoded_image);
        
        //store the decoded image//
        $storagePath = Storage::put('/signatures/'.$request->assid.'_driver_signature.png', $decoded_image);
        
        //store the file in the db//
        $signature->signature = 'signatures/'.$request->assid.'_driver_signature.png';
        $signature->save();

  
    }
16 Mar
4 days ago

joshblevins left a reply on Signature Pad With Ajax

I made the above changes now I am getting a file put error.

I have cleared the cache and config cache with no success.

[2019-03-16 14:57:25] production.ERROR: file_put_contents(/home/emscomplete/public_html/storage/app/signatures): failed to open stream: Is a directory {"userId":450,"email":"[email protected]","exception":"[object] (ErrorException(code: 0): file_put_contents(/home/emscomplete/public_html/storage/app/signatures): failed to open stream: Is a directory at /home/emscomplete/public_html/vendor/league/flysystem/src/Adapter/Local.php:199)
[stacktrace]
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'file_put_conten...', '/home/emscomple...', 199, Array)
#1 /home/emscomplete/public_html/vendor/league/flysystem/src/Adapter/Local.php(199): file_put_contents('/home/emscomple...', 'da39a3ee5e6b4b0...', 2)
#2 /home/emscomplete/public_html/vendor/league/flysystem/src/Filesystem.php(99): League\Flysystem\Adapter\Local->update('signatures', 'da39a3ee5e6b4b0...', Object(League\Flysystem\Config))
#3 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php(180): League\Flysystem\Filesystem->put('signatures', 'da39a3ee5e6b4b0...', Object(League\Flysystem\Config))
#4 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php(399): Illuminate\Filesystem\FilesystemAdapter->put('/signatures', 'da39a3ee5e6b4b0...')
#5 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(223): Illuminate\Filesystem\FilesystemManager->__call('put', Array)
#6 /home/emscomplete/public_html/app/Http/Controllers/Web/DrivingAssessmentsController.php(271): Illuminate\Support\Facades\Facade::__callStatic('put', Array)
#7 [internal function]: Vanguard\Http\Controllers\Web\DrivingAssessmentsController->saveSignature(Object(Illuminate\Http\Request))
#8 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#9 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('saveSignature', Array)
#10 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Vanguard\Http\Controllers\Web\DrivingAssessmentsController), 'saveSignature')
#11 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\Routing\Route->runController()
#12 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(665): Illuminate\Routing\Route->run()
#13 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#14 /home/emscomplete/public_html/app/Http/Middleware/Authenticate.php(45): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#15 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Vanguard\Http\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#17 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#18 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#19 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(68): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#22 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#24 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#25 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#27 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#30 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#31 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#32 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#33 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#36 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#37 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(642): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#38 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(608): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#39 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(597): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#40 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#41 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#42 /home/emscomplete/public_html/vendor/proengsoft/laravel-jsvalidation/src/RemoteValidationMiddleware.php(53): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#43 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Proengsoft\JsValidation\RemoteValidationMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#45 /home/emscomplete/public_html/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#46 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#47 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 /home/emscomplete/public_html/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#49 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#50 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#51 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#52 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#53 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#54 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#55 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#56 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#57 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#58 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#59 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#60 /home/emscomplete/public_html/app/Http/Middleware/VerifyInstallation.php(29): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#61 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Vanguard\Http\Middleware\VerifyInstallation->handle(Object(Illuminate\Http\Request), Object(Closure))
#62 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#63 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#64 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#65 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#66 /home/emscomplete/public_html/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#67 /home/emscomplete/public_html/index.php(21): require_once('/home/emscomple...')
#68 {main}

joshblevins left a reply on Signature Pad With Ajax

@ARTCORE - This helped fix the problem now having problem with storing the image. I am gonna research the method the controller is using and try and fix. I will post back if I have more difficulties.

joshblevins left a reply on Signature Pad With Ajax

I have changed the ajax to add the event.preventDefault(); like so.

<script>

$(function () {

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            var signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
              backgroundColor: 'rgba(255, 255, 255, 0)',
              penColor: 'rgb(0, 0, 0)'
            });
            var saveButton = document.getElementById('save');
            var cancelButton = document.getElementById('clear');


            saveButton.addEventListener('click', function (event) {

                 event.preventDefault();
                 
                if (signaturePad.isEmpty()) {
                    sweetAlert("Oops...", "Please provide signature first.", "error");
                } else {

                    // do ajax to post it
                    $.ajax({
                        url : '{{route('driving.signature')}}',
                        type: 'POST',
                        data : {
                            signature: signaturePad.toDataURL('image/png'),
                            position: $('#position').val()
                        },
                        success: function(response)
                        {
                            swal({
                              title: "Signature Saved",
                              text: "Your signature has now been stored.",
                              icon: "success",
                            });
                            window.setTimeout(function(){window.location.reload()}, 3000);
                            //data - response from server
                            console.log(response);
                        },
                        error: function(response)
                        {
                            
                            console.log(response);
                        }
                    });
                }

            });

            cancelButton.addEventListener('click', function (event) {
                signaturePad.clear();
            });

        });
 </script>

I also placed only return response($request->signature); in the controller to see if I am getting any data from the signature pad. The log error I get is below.

[2019-03-16 13:50:13] production.ERROR: Call to undefined function Vanguard\Http\Controllers\Web\respoonse() {"userId":450,"email":"[email protected]","exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to undefined function Vanguard\Http\Controllers\Web\
espoonse() at /home/emscomplete/public_html/app/Http/Controllers/Web/DrivingAssessmentsController.php:260)
[stacktrace]
#0 [internal function]: Vanguard\Http\Controllers\Web\DrivingAssessmentsController->saveSignature(Object(Illuminate\Http\Request))
#1 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#2 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('saveSignature', Array)
#3 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Vanguard\Http\Controllers\Web\DrivingAssessmentsController), 'saveSignature')
#4 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\Routing\Route->runController()
#5 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(665): Illuminate\Routing\Route->run()
#6 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#7 /home/emscomplete/public_html/app/Http/Middleware/Authenticate.php(45): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#8 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Vanguard\Http\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))
#9 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#10 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#11 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#12 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#13 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(68): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#14 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#15 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#16 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#17 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#18 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#19 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#20 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#21 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#22 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#23 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#26 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#27 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#28 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#29 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#30 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(642): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#31 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(608): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#32 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(597): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#33 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#34 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#35 /home/emscomplete/public_html/vendor/proengsoft/laravel-jsvalidation/src/RemoteValidationMiddleware.php(53): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#36 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Proengsoft\JsValidation\RemoteValidationMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#37 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#38 /home/emscomplete/public_html/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#39 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 /home/emscomplete/public_html/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#42 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#43 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#44 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#45 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#46 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#47 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#48 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#49 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#50 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#51 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#52 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#53 /home/emscomplete/public_html/app/Http/Middleware/VerifyInstallation.php(29): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#54 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Vanguard\Http\Middleware\VerifyInstallation->handle(Object(Illuminate\Http\Request), Object(Closure))
#55 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#56 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#57 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#58 /home/emscomplete/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#59 /home/emscomplete/public_html/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#60 /home/emscomplete/public_html/index.php(21): require_once('/home/emscomple...')
#61 {main}
15 Mar
5 days ago

joshblevins started a new conversation Signature Pad With Ajax

I have been attempting to follow advice from https://laracasts.com/discuss/channels/general-discussion/signature-pad to set up a signature pad.

When I click submit the page goes to a white screen and I am unable to locate and errors being saved in the log.

Controller

/**
     * Save Signature
     *
     * @param Request $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function saveSignature(Request $request)
    {
        if($request->ajax()){
        
        $user = $request->session()->get('user');

        $signature = DrivingAssessments::find($request->assid);
       
        $data_uri = $request->signature;
        $encoded_image = explode(",", $data_uri);
        //$decoded_image = base64_decode($encoded_image);

        $sig = sha1($request->session()->get('user.first_name').$request->session()->get('user.last_name')).$request->addid. "_driver_signature.png";
        $folder = '/signatures/';

        Storage::put($folder, $sig);


        $signature->signature = $encoded_image;
        $signature->save();

        $request->session()->put('user', $user->load('account', 'signature'));
        //return back();
        return response('ajax ran');
        }else{
            return response('ajax did not run');
        }
        
    }

Form

<!--Panel-->
                <form  method="post" enctype="multipart/form-data" class="ansform"> <!--Panel-->

                    {{ csrf_field() }}
                    <div class="wrapper">

                        <canvas id="signature-pad" class="signature-pad" width=400 height=200></canvas>
                    </div>
                    <div>
                        <input type="hidden" name="assid" value="{{$da->id}}">
                        <button id="save">Save</button>
                        <button id="clear">Clear</button>
                    </div>
                    <!--/.Panel-->
                </form>

js/ajax

<script>

$(function () {

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            var signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
              backgroundColor: 'rgba(255, 255, 255, 0)',
              penColor: 'rgb(0, 0, 0)'
            });
            var saveButton = document.getElementById('save');
            var cancelButton = document.getElementById('clear');


            saveButton.addEventListener('click', function (event) {
                if (signaturePad.isEmpty()) {
                    sweetAlert("Oops...", "Please provide signature first.", "error");
                } else {

                    // do ajax to post it
                    $.ajax({
                        url : '{{route('driving.signature')}}',
                        type: 'POST',
                        data : {
                            signature: signaturePad.toDataURL('image/png'),
                            position: $('#position').val()
                        },
                        success: function(response)
                        {
                            swal({
                              title: "Signature Saved",
                              text: "Your signature has now been stored.",
                              icon: "success",
                            });
                            window.setTimeout(function(){window.location.reload()}, 3000);
                            //data - response from server
                            console.log(response);
                        },
                        error: function(response)
                        {
                            
                            console.log(response);
                        }
                    });
                }

            });

            cancelButton.addEventListener('click', function (event) {
                signaturePad.clear();
            });

        });
 </script>

route

Route::post('da/signature', '[email protected]')->name('driving.signature');
05 Mar
2 weeks ago

joshblevins left a reply on Counting From Relationships

@RDELORIER - Out of curiosity... Doesn't using the DB facade compromise security..... "I could be way off base just going off of something I recently read and cant place where I read it at the moment."

joshblevins left a reply on Counting From Relationships

@CRONIX - Sorry I did neglect to look at the link.

So is it even possible to do this without having a station column in bad run sheets to link it to the station table?

I've tried this below.

$station = Station::withCount(['Employees', 'Employees.BadRunSheets' => function ($q){
            $q->where('status', 5);
        }])->get();

I get this error.

BadMethodCallException thrown with message "Method Illuminate\Database\Query\Builder::Employees.BadRunSheets does not exist."

My thought would be I would have to get each station and then employee and calculate the number a bad run sheets they have in a for each loop after the station query is ran.

joshblevins left a reply on Counting From Relationships

I am trying to get the count of how many reports are per each station. So the mysql for it would be

SELECT COUNT(*) FROM badrunsheets AS b
LEFT JOIN employees AS e ON b.employee = e.user_id
where b.status = 5
GROUP BY e.primary_station
04 Mar
2 weeks ago

joshblevins started a new conversation Counting From Relationships

I have 3 tables

Stations |id|name|

Employees |id|name|station|

Bad Run Sheets |id|employee_id|

I am trying to get a count of Bad Run Sheets per station where my relationship is employees have multiple bad run sheets and then an employee belongs to a station.

I have tried this below however it pulls the right queries I cant seem to display the counts for the employee relationship in the view.

$brs = BadRunSheet::with(['Employee' => function($query){
           return $query->selectRaw('count(*) as')
           ->groupBy('primary_station');
        }])->get();
20 Feb
1 month ago

joshblevins left a reply on Building Form With Questions

@CRONIX - Sorry bout that I didn’t catch it wasn’t formatted correctly

joshblevins started a new conversation Building Form With Questions

I am building a form that has a list of questions.

Questions come from a separate table.

Code for Form ///

{{csrf_field()}} Select Authoring Employee @foreach($employees as $id => $employee) employee_id == $id) selected @endif @else @if(old('employee_id') == $id) selected @endif @endif >{{$employee}} @endforeach @if ($errors->has('employee_id')) The date field is required. @endif
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-12">
                        <div class="md-form">
                            <select class="mdb-select" id="employee_id" name="unit" searchable="Search here.." >
                                <option value="default" disabled selected>Select Unit Reviewed</option>
                                @foreach($units as $id => $unit)
                                <option value="{{$id}}" 
                                        @if($edit) 
                                        @if($review->employee_id == $id) 
                                        selected
                                        @endif
                                        @else
                                        @if(old('unit') == $id) selected @endif 
                                        @endif
                                        >{{$unit}}</option>
                                @endforeach          
                            </select> 
                            @if ($errors->has('employee_id')) 
                            The date field is required.
                            @endif

                        </div>
                    </div>
                    <div class="col-lg-4 col-md-12">
                        <div class="md-form">
                            <input placeholder="Date of Review" type="text" id="date" name="date"  class="form-control datepicker" value="@if($edit) {{$review->date}} @else{{old('date')}}@endif" >
                            <label for="doi">Date of Run</label>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-lg-4 col-md-12">
                        <div>Start Time</div>
                        <div class="form-group">
                            <div class="input-group date" id="datetimepicker1" data-target-input="nearest">
                                <input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
                                <div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
                                    <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="col-lg-4 col-md-12">
                        <div>End Time</div>
                        <div class="form-group">
                            <div class="input-group date" id="datetimepicker1" data-target-input="nearest">
                                <input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
                                <div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
                                    <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-lg-4 col-md-12">
                        

                </div>
                </div>
                
                <div class="row">
                    @foreach($questions as $row)
                    <div class="col-lg-6">
                        {{$row->question}}
                    </div>
                    
                    <div classs="col-lg-6">
                        <div class="d-flex justify-content-center my-4">
                          <span class="font-weight-bold indigo-text mr-2 mt-1">0</span>
                          <form class="range-field ">
                            <input class="border-0" type="range" min="0" max="4"  value="4"/>
                          </form>
                          <span class="font-weight-bold indigo-text ml-2 mt-1">4</span>
                        </div>
                    </div>
                    <hr>
                    @endforeach
                    </div>

            </form>

///

I store the date of run/review, start time, endtime, and employee in a separate table.

I am having difficulties determining the best way to store the scores of each question on the form and then be able to pull the responses back out to put on a report.

Any guidance appreciated.

08 Feb
1 month ago

joshblevins left a reply on Ajax Call Every 10 Min

I was able to work it out. The controller I was using require authentication. By changing to a controller that did not require auth... the Ajax call now works.

joshblevins left a reply on Ajax Call Every 10 Min

401 Not Authorized

joshblevins started a new conversation Ajax Call Every 10 Min

I am attempting to run a script to report a ip address is displaying a page using ajax and then update the db the last time the ip address was seen on a specific page.

I continue to ger Request failed: error in console log. Laravel log shows no errors....

///

//Call the yourAjaxCall() function every 60000 millisecond setInterval("yourAjaxCall()",1000); function yourAjaxCall(){ $.ajaxSetup({
        headers: {

            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

        }

    });


    var request = $.ajax({
        url: "/narcoticStatus",
        type: "POST",
        data: {id : 1},
        dataType: "html"
    });

    request.done(function(msg) {
        console.log( msg );
    });

    request.fail(function(jqXHR, textStatus) {
        console.log( "Request failed: " + textStatus );
    });


}
///

Controller /// public function narcoticStatus(Request $request)

{

    $ip = "69.135.109.230";
    
    $station = Station::where('narcotic_computer', $ip)->first();
    
    if($station){
        $station->nc_last_connection = date('Y-m-d H:i:s');
        $station->nc_status = 1;
        
        $station->save();
        
        
    }else{
        dd($ip);
    }

    return response()->json(['success'=>'Got Simple Ajax Request.']);

}

///

route /// Route::post('narcoticStatus', '[email protected]'); ///

31 Jan
1 month ago

joshblevins started a new conversation Calculation In Controller

I have some calculations on one of my controllers. These calculations may be used in other areas of my application. I feel like this is not the most appropriate method of completing this process and I am either duplicating work or adding more code than necessary. If someone could review what I am doing below... provide feedback and if possible what I can search to learn a better method?

 public function index()
    {
        $btd = Employee::where('driver', 5)->where('status', '<', 8)->get();
        
        $ftoems = Employee::where('driver', 5)->where('status', '<', 8)->get();
        
        $ftowc = Employee::where('driver', 5)->where('status', '<', 8)->get();
        
        $medic_count = Employee::where('primary_position', 5)->where('status', 5)->count();
        
        $aemt_count = Employee::where('primary_position', 4)->where('status', 5)->count();
        
        $emt_count = Employee::where('primary_position', 3)->where('status', 5)->count();
        
        $cct_count = Employee::where('primary_position', 8)->where('status', 5)->count();
        
        $wc_count = Employee::where('primary_position', 11)->where('status', 5)->count();
        
        $dispatcher_count = Employee::where('primary_position', 2)->where('status', 5)->count();
        
        $e_driver_count = Employee::where('driver', 1)->where('status', 5)->count();
        
        $n_driver_count = Employee::where('driver', 6)->where('status', 5)->count();
        
        $btd_count = Employee::where('driver', 5)->where('status', 5)->count();
        
        $non_driver_count = Employee::where('driver', 0)->where('status', 5)->count();
        
        $courses = CourseCompletions::with('employee', 'classesfrom.course')->whereDate('created_at', Carbon::today())->get();
        
        
        
        return view('hr.index', compact('btd', 'ftoems', 'ftowc', 'medic_count', 'aemt_count', 'emt_count', 'cct_count', 'wc_count', 'dispatcher_count', 'e_driver_count', 'n_driver_count', 'btd_count', 'non_driver_count', 'courses'));
    }
22 Dec
2 months ago

joshblevins left a reply on Drag Task To Assign To Employee

@SNAPEY - This looks really good if I can get through the documentation and understand it...

17 Dec
3 months ago

joshblevins started a new conversation Drag Task To Assign To Employee

I am not sure exactly what I need to search for to get info on how to build this. Not looking for someone to do this for me but to point me into the right direction of searching, it seems I am not using the proper terms to search.

<div class="row">
    <div class="col-lg-8">
        @foreach($mechanics as $row)
        ** Card for Employee**
        @endforeach
    </div>
    
    <div class="col-lg-8">
        
        ***Want to drag task to the employee and update the assigned_to field in the task****
        @foreach($tasks as $row)
        ** List for Tasks**
        @endforeach
    </div>
</div>
30 Nov
3 months ago

joshblevins left a reply on Schedule

@snapey can I safely move the artisan file to the parent folder or

23 Nov
3 months ago

joshblevins left a reply on Schedule

It appears this is working now, When I go and check my sendgrid account the emails are being blocked by the receiving server.

joshblevins left a reply on Schedule

@SNAPEY - Running scheduled command: '/opt/cpanel/ea-php72/root/usr/bin/php' 'artisan' Certifications:Expired > '/dev/null' 2>&1

is what happens when I run the command in the cmd line

joshblevins started a new conversation Schedule

I have followed the tutorial to set up the schedule cron and will not run the cron jobs.

This is my cron setting

          • /usr/local/bin/php /home/emscomplete/public_html/artisan schedule:run >> /dev/null 2>&1

I am not sure what other info to provide here. I even tried to have the email sent that the cron ran by removing the 2>&1 at the end of the cron command

11 Nov
4 months ago

joshblevins left a reply on A New Open Source Package For Google Places Api.

Here is what I have tried

First I set api key in google.php --> got error api key not set.

controller

<?php

namespace Vanguard\Http\Controllers\Web;
use Vanguard\Http\Controllers\Controller;
use Illuminate\Http\Request;

use GooglePlaces;



class AutoCompleteController extends Controller
{

    function index()
    {
     return view('autocomplete');
    }

    function fetch(Request $request)
    {
     if($request->get('query'))
     {
        
         
        $googlePlaces = new GooglePlaces('my api key is here');
        $response = $googlePlaces->placeAutocomplete('my_id_here');
         

        echo $response;
     }
    }
}

I get error

{message: "Call to undefined method SKAgarwal\GoogleApi\Facade::findPlace()",…} exception: "Symfony\Component\Debug\Exception\FatalThrowableError" file: "/home/emscomplete/public_html/app/Http/Controllers/Web/AutoCompleteController.php" line: 27 message: "Call to undefined method SKAgarwal\GoogleApi\Facade::findPlace()" trace: [{function: "fetch", class: "Vanguard\Http\Controllers\Web\AutoCompleteController", type: "->"}, {,…},…]

10 Nov
4 months ago
04 Nov
4 months ago

joshblevins left a reply on Adding Values Into An Array.

Ok would this bring back results if there was a month with 0 results or would it continue to jump to the next month with results

joshblevins started a new conversation Adding Values Into An Array.

I am trying to build data for a chart. I have a working query which pulls the data from my db. However there is times where their is a month that does not have any data.

The chart displays the last 12 months of medication usage per medication.....

I was thinking that I need to do a for each loop to build an array of data. However wasn't sure exactly how to go about that. If someone could lead me into the right direction or tutorial that would be appreciated.

Query

        $nw = NarcoticWaste::with(['vial' => function($query) 
    {
        $query->select('medication', DB::Raw('MONTH(created_at) month'),DB::raw('count(*) as use_count'), DB::Raw('MONTH(date) monnum'));
        $query->groupBy('medication', 'month');
    }, 'vial.medications'])
        ->withCount(['vial'])
        ->orderBy('monnum', 'desc')
        ->get();
        
      
        
    foreach($nw as $n)
    {
            
        $n->month;
        $n->medication;
        $n->use_count; 
    }

Chart

<script>
    //line
var ctxL = document.getElementById("lineChart").getContext('2d');
var myLineChart = new Chart(ctxL, {
  type: 'line',
  data: {
    labels: [<?php echo $labels ?>],
    datasets: [{
        label: "Insufficient",
        data: [{{$nw->where('grade', 2)->pluck('count')->implode(', ')}}],
        backgroundColor: [
          'rgba(105, 0, 132, .2)',
        ],
        borderColor: [
          'rgba(200, 99, 132, .7)',
        ],
        borderWidth: 2
      },
      {
        label: "Sufficient",
        data: [{{$nw->where('grade', 1)->pluck('count')->implode(', ')}}],
        backgroundColor: [
          'rgba(0, 137, 132, .2)',
        ],
        borderColor: [
          'rgba(0, 10, 130, .7)',
        ],
        borderWidth: 2
      }
    ]
  },
  options: {
    responsive: true
  }
});
</script>
19 Oct
5 months ago
17 Oct
5 months ago

joshblevins left a reply on Count From Two Unrelated Tables

Attendance Model

<?php

namespace Vanguard;



class Attendance extends Model
{
    protected $table= 'attendance';
    
    public $timestamps = true;
    
    public function employee()
    {
    return $this->belongsTo(Employee::class, 'user_id', 'user_id');
    }

    public function punch()
    {
        return $this->belongsTo(schedule::class, 'schedule_id', 'id');
    }
    
     public function type()
    {
        return $this->belongsTo(AttendanceOccurance::class, 'occurance_type');
    }
        
}

Attendance Migration

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class NewAttendanceTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('attendance', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->string('user_id')->index();
            $table->string('occurance_type')->index();
            $table->date('date');
            $table->string('added_by');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('attendance');
    }
}

Compliance Controller

<?php

namespace Vanguard;



class EmployeeEncounters extends Model
{
    public function Employee()
    {
        return $this->belongsTo(Employee::class, 'user_id', 'user_id');
    }
    
    public function Policies()
    {
        return $this->hasOne(Policies::class, 'id', 'policy');
    }
    
    public function EncounterAttachment()
    {
        return $this->hasMany(EncounterAttachment::class, 'pid', 'id');
    }
    
    public function EncounterNote()
    {
        return $this->hasMany(EncounterNote::class, 'pid', 'id');
    }
    
    public function EncounterReport()
    {
        return $this->hasMany(IncidentReports::class, 'incident_id', 'id');
    }
}

Compliance Migration

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class NewTableEmployeeEncounters extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('employee_encounters', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->date('doi');
            $table->string('user_id', '10');
            $table->string('encounter_type', '4');
            $table->string('department', '4');
            $table->string('policy', '4');
            $table->string('follow_up', '2');
            $table->date('fu_date');
            $table->text('incident_report');
            $table->text('plan');
            $table->string('associated');
            $table->string('added_by');
            $table->string('status');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('employee_encounters');
    }
}

16 Oct
5 months ago

joshblevins started a new conversation Count From Two Unrelated Tables

I have two tables employee attendance and employee encounters.

These two tables do not have a direct relations however they have the same field user_id.

Is it possible to do this. I am trying to build a report like this.

Employee Name | Attendance Counts | Compliance Counts

This is what I have so far for the employee and attendance.

       $employees = Employee::where('status', 5)->orderBy('last_name')->paginate(100);

$employeesCount = Attendance::whereBetween('date', ['2018-07-01', '2018-09-30'])
            ->whereIn('user_id', $employees->pluck('id')->toArray())
            ->select('user_id', DB::raw('count(*) as total'), DB::raw('count(IF(occurance_type = 0,1,NULL)) hour'), DB::raw('count(IF(occurance_type = 2,1,NULL)) t5'), DB::raw('count(IF(occurance_type = 4,1,NULL)) t120'), DB::raw('count(IF(occurance_type = 6,1,NULL)) b'), DB::raw('count(IF(occurance_type = 7,1,NULL)) ncns'), DB::raw('count(IF(occurance_type = 8,1,NULL)) co'), DB::raw('count(IF(occurance_type = 9,1,NULL)) ntc'), DB::raw('count(IF(occurance_type = 11,1,NULL)) lo'))
            ->groupBy('user_id')
            ->get();
            
            

$employees->map(function ($employee) use ($employeesCount) {
    $count = $employeesCount->where('user_id', $employee->id)->first();

    if (!$count) {
        $employee->hour32 = 0;
        $employee->late = 0 ;
        $employee->late120 = 0;
        $employee->blackout = 0;
        $employee->nocall = 0;
        $employee->calloff = 0;
        $employee->ntc = 0;
        $employee->lo = 0;
    } else {
        $employee->hour32 = $count->hour * 0;
        $employee->late = $count->t5 ;
        $employee->late120 = $count->t120 * 3;
        $employee->blackout = $count->b * 7;
        $employee->nocall = $count->ncns * 7;
        $employee->calloff = $count->co * 3;
        $employee->ntc = $count->ntc * 2;
        $employee->lo = $count->lo * 2;
    }
    $employee->total = $employee->hour32 + $employee->late + $employee->late120 + $employee->blackout + $employee->nocall +$employee->calloff + $employee->ntc + $employee->lo;

    return $employee;
});
14 Oct
5 months ago

joshblevins left a reply on Get Count On Relationship For Each Row

So now I have tried

$nw = NarcoticWaste::
        withCount(['vial' => function($query)
        {
            $query->select('medication', DB::raw('count(*) as use_count'));
            $query->groupBy('medication');
        }])
            ->get();
            
       foreach($nw as $nw)
       {
        $nw->vial_count;
       }

on view

@foreach($nw as $nw)

{{$nw}},
@endforeach

The response is 1 1 1

Which I would assume should have been 1, 1 since I added another record for a different medication.

When I try $nw->vial _count I get an error Trying to get property 'vial_count' of non-object

joshblevins started a new conversation Get Count On Relationship For Each Row

I have three tables with working relationships set up in the model's.

  1. narcotic_wastes (holds forms for each time an employees wastes a form)

  2. controlled_substances (Holds medication data of each medication vial on hand) joined to narcotic_wastes by vial_id.

  3. medications (Holds medication names) joined to constrolled_substances by id

I am trying to query a count for each medication used each month for the last 12 months.

I have started to build the query but have got stuck at grouping by each medication.

$nw = NarcoticWaste::with(['vial' => function($query)
        {
            $query->select('medication', DB::raw('count(*) as use_count'));
            $query->groupBy('medication');
        }])
            ->get();
            
        if($nw->vial->isEmpty()){
            
        }else{
          foreach ($nw as $nw)
        {
            $nw->medication->count();
        }  
        }

I get an error showing collection 'vial' does not exist.

When I run this query;

select `medication`, count(*) as use_count from `controlled_substances` where `controlled_substances`.`id` in ('259') group by `medication`

I get a response of medication 1 and use_count 1. This is the correct response as for their is only one record.

09 Oct
5 months ago

joshblevins left a reply on Laravel View Returns White Screen

There was def some type of memory limit issue. @D9705996. Your solution solved the page load using my original code.

@bobbybouwmann your solution brought a faster response on page load.

Thank you guys for all your help.

08 Oct
5 months ago

joshblevins left a reply on Laravel View Returns White Screen

@bobbybouwmann

I changed the $count query as you suggested and I now can return results.

public function report(Request $request)
    {
     
        
        //get all employees
      
        $employees = Employee::where('status', 5)->paginate(100);
        
        foreach($employees as $employee)
        {
            //get employees attendance record.
            
            $count = Attendance::whereBetween('date', ['2018-07-01', '2018-09-30'])
            ->where('user_id', $employee->id)
            ->select('user_id', DB::raw('count(*) as total'), DB::raw('count(IF(occurance_type = 0,1,NULL)) hour'), DB::raw('count(IF(occurance_type = 2,1,NULL)) t5'), DB::raw('count(IF(occurance_type = 4,1,NULL)) t120'), DB::raw('count(IF(occurance_type = 6,1,NULL)) b'), DB::raw('count(IF(occurance_type = 7,1,NULL)) ncns'), DB::raw('count(IF(occurance_type = 8,1,NULL)) co'), DB::raw('count(IF(occurance_type = 9,1,NULL)) ntc'), DB::raw('count(IF(occurance_type = 11,1,NULL)) lo'))
            ->groupBy('user_id')
            ->first();
            
          
            
            if(!$count){
            
            $employee->hour32 = 0;
                $employee->late = 0 ;
                $employee->late120 = 0;
                $employee->blackout = 0;
                $employee->nocall = 0;
                $employee->calloff = 0;
                $employee->ntc = 0;
                $employee->lo = 0;
            }else{

            $employee->hour32 = $count->hour * 0;
            $employee->late = $count->t5 ;
            $employee->late120 = $count->t5 * 3;
            $employee->blackout = $count->b * 7;
            $employee->nocall = $count->ncns * 7;
            $employee->calloff = $count->co * 3;
            $employee->ntc = $count->ntc * 2;
            $employee->lo = $count->lo * 2;
           
            }
             $employee->total = $employee->hour32 + $employee->late + $employee->late120 + $employee->blackout + $employee->nocall +$employee->calloff + $employee->ntc + $employee->lo;
        }
        
        return view('attendance.report', compact('employees'));
    }

@D9705996

I was able to return results but not all 750 results so it appears I am timing out somewhere.

php log file has nothing in it for this evening, I will check and see if there are any server errors. my memory limit in php.ini is 1024m. Can I fix this by simply upping my memory limit.

The only time that I need to display all 750 results is when printing. Otherwise it is okay to paginate or search.

joshblevins started a new conversation Laravel View Returns White Screen

I am trying to perform a calculation inside my laravel controller and pass it to my view.

When I remove my calculation and then visit my view it displays appropriately. However when the calculation is in the controller it only displays a white page and no errors are displayed as for the stack trace will not show up either.

//Controller

    <?php
    public
    function report(Request $request)
    {
    
    
        //get all employees
    
        $employees = Employee::where('status', 5)->get();
    
        foreach ($employees as $employee) {
            //get employees attendance record.
    
            $count = Attendance::
            whereBetween('date', ['2018-07-01', '2018-09-30'])
                ->where('user_id', 1000)
                ->select('user_id', DB::raw('count(*) as total'), DB::raw('count(IF(occurance_type = 0,1,NULL)) hour'), DB::raw('count(IF(occurance_type = 2,1,NULL)) t5'), DB::raw('count(IF(occurance_type = 4,1,NULL)) t120'), DB::raw('count(IF(occurance_type = 6,1,NULL)) b'), DB::raw('count(IF(occurance_type = 7,1,NULL)) ncns'), DB::raw('count(IF(occurance_type = 8,1,NULL)) co'), DB::raw('count(IF(occurance_type = 9,1,NULL)) ntc'), DB::raw('count(IF(occurance_type = 11,1,NULL)) lo'))
                ->groupBy('user_id')
                ->get();
    
    
            if (!$count->isEmpty()) {
    
                $employee->hour32 = 0;
                $employee->late = 0;
                $employee->blackout = 0;
                $employee->nocall = 0;
                $employee->calloff = 0;
                $employee->ntc = 0;
                $employee->lo = 0;
            } else {
    
                $employee->hour32 = $count->hour * 0;
                $employee->late = $count->t5;
                $employee->blackout = $count->b * 7;
                $employee->nocall = $count->ncns * 7;
                $employee->calloff = $count->co * 3;
                $employee->ntc = $count->ntc * 2;
                $employee->lo = $count->lo * 2;
    
            }
            $employee->total = $employee->hour32 + $employee->late + $employee->blackout + $employee->nocall + $employee->calloff + $employee->ntc + $employee->lo;
        }
    
        return view('attendance.report', compact('employees'));
    }
    ?>

//view

    @extends('layouts.app')
    
    @section('page-title', trans('app.dashboard'))
    @section('page-heading', trans('app.dashboard'))
    
    @section('breadcrumbs')
    <li class="breadcrumb-item active">
        @lang('Companies')
    </li>
    @stop
    
    @section('content')
    <div class="row">
        <div class="col-sm-12 col-lg-8">
            <h1>Employee Quarterly Attendance Report</h1>
        </div>
        <div class="col-sm-12 col-lg-4">
            <table>
                <tbody>
                    <tr>
                        <td>Report</td>
                        <td>Attendance Report</td>
                    </tr>
                    <tr>
                        <td>Start Date</td>
                        <td>July 01, 2018</td>
                    </tr>
                    <tr>
                        <td>End Date</td>
                        <td>September 30, 2018</td>
                    </tr>
                </tbody>
            </table>
        </div> 
    </div>
    <div class="row">
        @foreach($employees as $row)
        <div class="col-lg-12">
             123
        </div>
        @endforeach
    </div>
    @include('partials.toastr')
    
    
    @stop
    
    @section('styles')
    <style>
        .btn-link{
      border:none;
      outline:none;
      background:none;
      cursor:pointer;
      color:#0000EE;
      padding:0;
      text-decoration:underline;
      font-family:inherit;
      font-size:inherit;
    }
    </style>
    @stop
    
    @section('scripts')
    
    <script>
        // Data Picker Initialization
        $('.datepicker').pickadate();
    </script>
    @stop


27 Sep
5 months ago

joshblevins left a reply on A New Open Source Package For Google Places Api.

@SachinAgarwal please let us all know when you get your blog complete...

16 Sep
6 months ago

joshblevins started a new conversation Method Illuminate\Database\Query\Builder::routeNotificationFor Does Not Exist. Error Setting Up Notification

Controller

/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        
        
        $narlog = NarcoticLog::with('NarcoticBox')->find($id);
        
        $narcemail = NarcoticEmail::get();
        
        
        if($request->status == 1){
            
            
            //validate required fields
            $this->validate($request, [
                'unit' => 'required',
                'seal' => 'required',
                'tamper_seal' => 'required',
                'out_signature' => 'required',
                'witness_out' => 'required'
                
                
            ]);
            
            if($request->in_signature != $narlog->out_signature){
           
             
            // send notification using the "Notification" facade
                
           foreach ($narcemail as $email){
            Notification::send($email, new WrongNarcoticSignIn());
            }
       
            }
            $narlog->update($request->all());
           
            
        }elseif($request->status == 2){
            
          
            
            //validate required fields
            $this->validate($request, [
                'unit' => 'required',
                'seal' => 'required',
                'tamper_seal' => 'required',
                'in_signature' => 'required',
                'witness_in' => 'required'
            ]);
            
            if($request->in_signature != $narlog->out_signature){
           
           // send notification using the "Notification" facade
            
            foreach ($narcemail as $email){
            \Illuminate\Support\Facades\Notification::send($email, new WrongNarcoticSignIn());
            }
        }
            $narlog->update($request->all());
            
            
           
        }
        
        return view('timeclock.index')->with('success', 'You have successfully signed out your narcotics.');
    }

Notification File

<?php

namespace Vanguard\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Vanguard\NarcoticLog;
use Vanguard\NarcoticEmail;

class WrongNarcoticSignIn extends Notification
{
   use Queueable;

   

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct()
    {
        
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line('The system has detected a possible violation. ')
                    ->action('Notification Action', url('www.emscomplete.app'))
                    ->line('Thank you for using our application!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

Email Model



namespace Vanguard;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class NarcoticEmail extends Model
{
     protected $table = 'narcotic_email';

    public $timestamps = true;
}

10 Sep
6 months ago

joshblevins started a new conversation Duplicate Queries Ran

I have this controller

public function show($id)
    {
    //indicate this view is not editable
        $edit= false;
        
        //fetch todays date...
        $td = date('Y-m-d');
        
        //fetch current payperiod
        $payperiod = payperiods::whereRaw("start <= '$td' AND end >= '$td'")->first();
        
        //fetch start and end payperiod dates...
        $start = $payperiod->start;
        $end = $payperiod->end;
        
        //find employee with this pay period results
        
        $employees = Employee::with('timepunch')
                    ->whereHas('timepunch', function($q) use($start, $end){

                $q->whereRaw("time_in >= '$start' AND time_in <= '$end'");
                
            })
                    ->find($id);
          
    //populate mobile carriers data          
        $mobilecarriers = MobileCarrier::pluck('label','id');
        
   //return the view to the end user.

        return view('employee.show', compact('mobilecarriers', 'employees', 'start', 'end',  'edit'));


    }

When the page is loaded it loads appropriately however when the employees current time punches are loaded it loads all their time punch not just the ones that are coming from the date range as indicated. I noticed the time punch query is duplicated in the query list below.

However I can not figure out from the controller where the second query is coming from.

select * from `sessions` where `id` = 'TAjey0sXjBapvJmTu18kA5Nld2J73pv0tg5Ntg7G' limit 1
2.09ms/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:91emscompl_emscomplete
select * from `users` where `id` = '450' limit 1
420μs/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php:51emscompl_emscomplete
select * from `pay_periods` where start <= '2018-09-10' AND end >= '2018-09-10' limit 1
360μs/app/Http/Controllers/Web/EmployeeController.php:169emscompl_emscomplete
select * from `employees` where exists (select * from `time_punch` where `employees`.`user_id` = `time_punch`.`employee_id` and time_in >= '2018-09-03' AND time_in <= '2018-09-16') and `employees`.`id` = '2' limit 1
640μs/app/Http/Controllers/Web/EmployeeController.php:183emscompl_emscomplete
select * from `time_punch` where `time_punch`.`employee_id` in ('450')
450μs/app/Http/Controllers/Web/EmployeeController.php:183emscompl_emscomplete
select `label`, `id` from `mobile_carriers`
280μs/app/Http/Controllers/Web/EmployeeController.php:184emscompl_emscomplete
select * from `stations` where `stations`.`id` = '1' limit 1
360μsview::employee.show:19emscompl_emscomplete
select * from `employee_positions` where `employee_positions`.`id` = '2' limit 1
310μsview::employee.show:19emscompl_emscomplete
select * from `employee_state_certifications` where `employee_state_certifications`.`user_id` = '450' and `employee_state_certifications`.`user_id` is not null
990μsview::employee.partials.certifications:22emscompl_emscomplete
select * from `roles` where `roles`.`id` = '1' limit 1
350μs/app/Support/Authorization/AuthorizationUserTrait.php:51emscompl_emscomplete
select * from `pay_rates` where `pay_rates`.`user_id` = '450' and `pay_rates`.`user_id` is not null
370μsview::employee.partials.payrate:20emscompl_emscomplete
select * from `badrunsheets` where `badrunsheets`.`employee` = '450' and `badrunsheets`.`employee` is not null
30 Aug
6 months ago

joshblevins left a reply on Join On A Join

I did but will a join like that work on a elequent query or would I have to use the dB facade

joshblevins left a reply on Join On A Join

This is what I have tried however I can not get the insurance data to populate or query. No errors were kicked back.

accounting controller for report

  /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function payrollreport(Request $request)
    {
        //get payperiod start and end...
        $start= $request->start_date;
        $end = $request->end_date;
        
        //get all active employees with their time punches and pay rates...
        
        $employees = Employee::with(['timepunch', 'PayRate', 'Insurances'])
                        ->whereHas('timepunch', function($q) use($start, $end){

                                $q->whereRaw("time_in >= '$start' AND time_in <= '$end'");
                               
                            })
                            ->whereHas('PayRate', function($q) use($start, $end){

                                $q->where('status', '1');
                               
                            })
                            ->whereHas('Insurances', function($q) use($start, $end) {

                                $q->where('start', '<=', $start);
                               
                            })
                        ->where ('status', '=', '1')
                        ->orderBy('last_name')
                        ->get();
                        
                       
                        
        //return all data to payroll report.
        
        return view('accounting.reports.payroll_report', compact('employees', 'start', 'end'));
    }

Employee Model

 public function Insurances()
    {
        return $this->hasMany(EmployeeInsurance::class, 'user_id', 'user_id');
    }

EmployeeInsurance Model

<?php

namespace Vanguard;

use Illuminate\Database\Eloquent\Model;

class EmployeeInsurance extends Model
{
    protected $table = 'employee_insurances';

    public $timestamps = true;
    
    public function Employee()
    {
        return $this->belongsTo(Employee::class, 'user_id', 'user_id');
        return $this->hasOne(Insurances::class, 'insurance_id', 'id');
    }
}

Insurances Model

<?php

namespace Vanguard;

use Illuminate\Database\Eloquent\Model;

class Insurances extends Model
{
        protected $table = 'insurances';

    public $timestamps = true;
    
    public function Insurances()
    {
        return $this->belongsTo(EmployeeInsurance::class, 'insurance_id', 'id');
       
    }
}

29 Aug
6 months ago

joshblevins started a new conversation Join On A Join

Is it possible in elequent to do a join on a join.

For example Select * from tablea as a Left join tableb as b on a.id = b.aid Left join tablec as c on b.cid = c.id

So it would be an employee has many insurances and each insurance has one price.

28 Aug
6 months ago

joshblevins left a reply on Getting A Value From Query On Blade Via Further Query

Pondering I could do a loop on pay rates and an if statement then multiply each category as needed...

joshblevins left a reply on Getting A Value From Query On Blade Via Further Query

The pay rates are actually in the dB table however are joined to the employee table because each employee has multiple rates. And I wanted to be able to track pay rate changes.

So I did hard code a rate in testing the code. I ran into a spot getting each employees pay rate from the query for example.

Employee A worked 40 straight hours with 10 overtime hours.

Now from the pay rates table... how could I get the straight pay which to multiply by 40 and overtime to multiply by 10?

joshblevins left a reply on Getting A Value From Query On Blade Via Further Query

Yup most probably in over my head..... I’ll have try o do some research on your recommendation.

As for getting the pay rates will that have to be two separate queries or can it be together like it is