finchy70

finchy70

Member Since 2 Years Ago

Swansea

Head of Systems at EPS

Experience Points 12,990
Experience Level 3

2,010 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 93
Lessons
Completed
Best Reply Awards 1
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.

04 Jun
3 weeks ago

finchy70 left a reply on NotFoundHttpException In PhpUnit Caused By Redirect()->route()

I think I have managed to find the problem. It was in fact the $this->get('/diary/'.$job->id) because $job->id is null as the Job object was not persisted.

finchy70 started a new conversation NotFoundHttpException In PhpUnit Caused By Redirect()->route()

This simple test is failing.

/**
     * @test
     */
    public function it_can_create_a_job()
    {
        $client = create('App\Client');
        $job = make('App\Job', ['client_id' => $client->id]);
        $this->post('/jobs', $job->toArray())
            ->assertRedirect("/diary/1");

        $this->get('/diary/'.$job->id)
            ->assertSee($job->job_number)
            ->assertSee($client->name)
            ->assertSee($job->site);
    }

The error is Symfony\Component\HttpKernel\Exception\NotFoundHttpException:.

This seems to be caused by the redirect at the end of my controller code.

return redirect()->route('diary.show', $job->id);

It all seems to work but this failing test is annoying me. Any one got any ideas what I am missing?

21 May
1 month ago

finchy70 started a new conversation Group By And Count On Pivot Table.

I have an intermediate table match_player that holds a match_id and player_id. It's the belongsToMany relationship between Player and Match models. I want to get the player appearances which is a query that returns the player_id and the amount of times it occurs. I've tried this

$appearances = DB::select('match_player.player_id', DB::raw('count(match_player.match_id) match_id'))->groupBy('player_id')->get();

but i have a n idea it's a bit easier than this.

This results in an error Argument 1 passed to Illuminate\Database\Connection::prepareBindings() must be of the type array, object given

Can anyone help?

09 May
1 month ago

finchy70 left a reply on Open Local Folder In Finder/explorer From Laravel Web App

I know but the directors don't want to upload and download the documents. They want to just be able to open them and then save them to the drive. I'll probably build a local app with python and wx widgets.

finchy70 started a new conversation Open Local Folder In Finder From Laravel Web App

I need my Laravel app to open a specific folder on the local file system of my mac in finder. Is this possible? We have a locally stored directory which contains individual directories which contain job specific documentation. We want to keep these local and not upload them to the webserver. As everyone using this web app will be either on the office network or connected to it from home via vpn we like to be able to open the correct job directly in finder of windows explorer locally on the users machine.

26 Feb
3 months ago

finchy70 left a reply on Phpunit Not Using Phpunit.xml Settings

@KEL_ - I’ve pointed phpstorm at the phpunit.xml file and that seems to have fixed the issue. Can’t explain exactly what I’ve done as I’m away from my Mac but it was in the edit configuration settings accessible from the testing drop down at the top of PHPStorm. I configured a directory for Feature and another for Unit. I do like running the test from inside PHPStorm as it is so convenient.

finchy70 started a new conversation Phpunit Not Using Phpunit.xml Settings

My phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>

        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="BCRYPT_ROUNDS" value="4"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_CONNECTION" value="sync"/>
        <env name="MAIL_DRIVER" value="array"/>
        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>
    </php>
</phpunit>

When I run my tests with PHPStorm I get this error.

Testing started at 16:13 ...
/usr/local/Cellar/php/7.2.9_2/bin/php /Users/paulfinch/code/site/vendor/phpunit/phpunit/phpunit --no-configuration /Users/paulfinch/code/site/tests/Feature --teamcity
PHPUnit 7.5.4 by Sebastian Bergmann and contributors.


Illuminate\Database\QueryException : SQLSTATE[HY000] [1049] Unknown database 'site' (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')
 /Users/paulfinch/code/site/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
 /Users/paulfinch/code/site/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
 /Users/paulfinch/code/site/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
 /Users/paulfinch/code/site/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php:99
............

Was working fine so not sure whats happened.

Anyone having a simular problem?

18 Feb
4 months ago

finchy70 left a reply on [Vue Warn]: Cannot Find Element: #app

Moving the @include(partials.scripts) out of the div with id="app" did the job.

<body>
        <div id="app">
            <main class="container">
                @include('partials.nav')
                @include('partials.messages')
                @include('partials.banner')
                @yield('content')
                @include ('partials.footer')
            </main>
        </div>
        @include('partials.scripts')
    </body>

finchy70 started a new conversation [Vue Warn]: Cannot Find Element: #app

Every page I visit gives this error.

My layouts.app looks like this

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}"></script>

    <!-- Fonts -->
    <link rel="dns-prefetch" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600" rel="stylesheet" type="text/css">

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
    <main class="container">
        @include('partials.nav')
        @include('partials.messages')
        @include('partials.banner')
        @yield('content')
        @include ('partials.footer')
        @include('partials.scripts')
    </main>
</body>
</html>

The only view with a Vue.js componenet is this one.

@extends('layouts.app')
@section('content')
    <div class="row justify-content-center">
        <strong><h4>Create a New Vehicle</h4></strong>
    </div>
    <div id="app">
        <model :makes="{{ $makes }}"></model>
    </div>

@stop

This does not show the vue content. I have tried moving the div with the id="app" tag back to the layouts.app file but same problem.

14 Feb
4 months ago

finchy70 left a reply on Passing Variables To A HTML Mail Template And Displaying Them

I fixed the issue by creating an array containing only the questions.

$q_a = $vehicle_check->questions_answers;
            $questions = [];
            foreach($q_a as $q)
            {
                $questions[] = $q->question;
            }

finchy70 started a new conversation Passing Variables To A HTML Mail Template And Displaying Them

I use the following code to build an email in html. The variables have been passed to the view.

<div>
    <div class="row">
        <h2>
            Vehicle {{ $vehicle->reg }} has failed a vehicle check on {{today()->format('d-m-Y')}}.
        </h2>

    </div>
    <div class="row">
        <h2>
            <span style="color: red">{{Auth::user()->name}}</span> did not tick pass for the following questions.
        </h2>

    </div>

    <hr>
    @foreach($fault_check as $fault)
        <div class="row">
            <h3>{{ $questions[$fault-1]->question }}</h3>
        </div>
    @endforeach

    <hr>
    <h2>Notes Captured</h2>
    <p>{{$notes}}</p>
    <hr>

    Regards,<br>

    <h4>Web Master</h4>
    <h4>EPSConstruction Ltd</h4>
</div>

When the email arrives it looks like this.

Vehicle CP17 KVE has failed a vehicle check on 14-02-2019. Paul Finch did not tick pass for the following questions.

{"id":1,"order":1,"question":"Are the brakes working correctly?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":2,"order":2,"question":"Bodywork free of any damage?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":3,"order":3,"question":"Brake lights intact and working correctly?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":4,"order":4,"question":"First aid kit present and fully stocked?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":5,"order":5,"question":"Front N/S Tyre OK?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":6,"order":6,"question":"Front O/F Tyre OK?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":7,"order":7,"question":"Headlights and sidelights intact and working correctly?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":8,"order":8,"question":"Horn checked and working?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":9,"order":9,"question":"Indicators intact and working correctly?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":10,"order":10,"question":"Oil and Water levels checked?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":11,"order":11,"question":"Rear N/S Tyre OK?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":12,"order":12,"question":"Rear O/S Tyre OK?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":13,"order":13,"question":"Windscreen clear of chips and cracks?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"} {"id":14,"order":14,"question":"Windscreen washer level checked?","created_at":"2019-02-11 11:06:44","updated_at":"2019-02-11 11:06:44"}

Notes Captured Testing message.

Regards, Web Master EPSConstruction Ltd

Why is the value of $questions[n] being dispayed and not $questions[n]->question which is just the question.

If I use this route to display the message all works as it should.

Route::get('mailable', function () {
    $questions = VehicleQuestion::all();
    $vehicle = App\Vehicle::find(1);
    $faults = [1,5,7,8,9];
    $notes = "It's Fucked!!!";

    return new App\Mail\FaultsReported($vehicle, $faults, $questions, $notes);
});

Anyone have any advice please?

11 Feb
4 months ago

finchy70 left a reply on Capturing Checkboxes With An Array.

@click when using radio buttons they all share the answer[] name so only one button can be checked on the whole form.

finchy70 started a new conversation Capturing Checkboxes With An Array.

I have a form that contains a loop that displays a question and checkbox.

<form action="/vehicle_checks/{{$vehicle->id}}" method="POST" class="form-control">
            @csrf
            <label name="mileage" for="mileage">Please record the vehicle mileage.</label>
            <input type="number" name="mileage" class="form-control mb-2" required>

            @foreach($questions as $question)
                <div class="row">
                    <div class="col-8"><label for="answer[]" class="ml-2">{{$question->question}}</label></div>
                    <div class="col-4">
                        <div class="form_check form-check-inline">
                            <input class="mr-2" type="checkbox" name="answer[]" checked>Yes
                        </div>
                    </div>
                </div>
                <hr>
            @endforeach
            <label name="notes" for="notes"><strong>Record any notes if applicable.</strong></label>
            <textarea rows="5" class="form-control" name="notes"></textarea>
            <div class="row">
                <a href="/vehicle_checks/{{$vehicle->id}}" class="ml-auto btn btn-danger mt-3 mr-2">Cancel</a>
                <button type="submit" class="btn btn-success mt-3 mr-3">Save</button>
            </div>
        </form>
            

I an using answer[] to capture the status of the checkboxes but they only add to the array when set to "on" status. I need every value in the array with its on / off status so I can save the answer against the specific question. For example if someone saved the form without checking and checkbox the answer array would contain 14 values of "off" (as that is currently the amount of questions), or if they just check question 3 then answer[2] would be set to "on";

Is there a way to do this?

06 Feb
4 months ago

finchy70 left a reply on Htmlspecialchars Error

@cronix. Yeah sorry. Didn't mean to delete the post.

finchy70 started a new conversation Htmlspecialchars Error

When this code sends the empty array $list

 public function store(Request $request)
    {
        $questions = Question::orderBy('section_id', 'asc')->with('question_type')->get();
        $type = new PlantType;
        $type->make_id = $request->make;
        $type->name = $request->name;
        $type->save();
        Session::flash('flash', 'Added Successfully!!');
        $list = array();
        return view('plant_types.add_questions', compact('type', 'questions', 'list'));
    }

to my vue component

<template>
    <div>
        <div class="row">
            <div class="col-1">#</div>
            <div class="col-5">Question</div>
            <div class="col-2">Section</div>
            <div class="col-2">Type</div>
            <div class="col-2">Option</div>
        </div>
        <hr>
        <div v-for="question in questions">
            <div class="row">
                <div class="col-1">{{ question.id }}</div>
                <div class="col-5">{{ question.question }}</div>
                <div class="col-2">{{ question.section_id}}</div>
                <div class="col-2">{{ question.question_type.description}}</div>
                <div v-if="checkSelected(question.id)" class="col-2"><button @click="removeQuestion(question.id)" class="btn btn-warning btn-sm">Remove</button></div>
                <div v-else class="col-2"><button @click="addQuestion(question.id)" class="btn btn-success btn-sm">Add</button></div>
            </div>
            <hr>
        </div>
        <div class="row">
            <button class="btn btn-sm btn-info ml-auto mr-3" @click="saveQuestions()">Save Questions</button>
        </div>
    </div>

</template>

<script>
    export default {
        props: ["questions", "plant", "list"],

        data: function () {
            return {
                selected: [...this.list]
            }
        },

        mounted() {
            console.log(this.selected);
        },

        methods: {
            checkSelected: function (check) {
                var length = this.selected.length;
                for (var i = 0; i < length; i++) {
                    if (this.selected[i] === check) return true;
                }
                return false;
            },


            addQuestion: function (add) {
                this.selected.push(add)
                console.log("selected="+this.selected, "old="+this.list);
            },

            removeQuestion: function (remove) {
                var length = this.selected.length;
                for (var i = 0; i < length; i++) {
                    if (this.selected[i] === remove) this.selected.splice(i, 1);
                    console.log("selected="+this.selected, "old="+this.list);
                }
            },

            saveQuestions: function () {
                axios.post('/plant_types/questions', {

                    questions: this.selected,
                    plant: this.plant.id,
                    old: this.list
                })
                    .then(response => {
                        window.location.href = '/plant_types/' + this.plant.id;
                    })
                    .catch(e => {
                    })
            }
        }
    }
</script>

via this view

@extends('layouts.app')

@section('content')

    <div class="row justify-content-center">
        <div class="col-md-11">
            <div class="card card-default">
    
                <div class="card-header">
                    <h5>Questions for {{$type->name}}</h5>
                </div>
    
                <div class="card-body">
                    <question-selector :questions="{{$questions}}" :plant="{{$type}}" :list="{{$list}}" ></question-selector>
                </div>
            </div>
    
        </div>
    </div>

@stop

I get this error ErrorException thrown with message "htmlspecialchars() expects parameter 1 to be string, array given (View: C:\Users\Paul\code\TxTest\resources\views\plant_types\add_questions.blade.php)"

If the array is populated all works fine.

Anyone see what the problem is?

finchy70 left a reply on Sending Session Message With Window.location.href

You are right. I over complicated the matter.

Session::flash('flash', 'Updated Successfully!!);

I'd used

Session::flash('success', 'Updated Successfully!!);

and got the Bootstrap messages.

finchy70 left a reply on Sending Session Message With Window.location.href

Not really explained this very well. I have built the Vue Flash message component in Episode 29 of Lets build a forum with Laravel.

I am redirecting from my component after the response from the back end. This ensures my data is updated before I display it. I want to redirect to '/plant_types/'+this.plant.id and then display a the success message. As I'm redirecting from the component I used

window.location.href = '/plant_types/'+this.plant.id;

If I try to redirect to the page from the laravel controler with no response the axios post fails with a 500 error.

Can I redirect from the vue component with the equivalent of the ->with('flash', 'Updated Questions!!') so my Vue flash component works.

finchy70 left a reply on Sending Session Message With Window.location.href

Yes but my component posts to laravel and on response redirects to window.location.href = '/plant_types/'+this.plant.id; to ensure the data has been updated.

finchy70 started a new conversation Sending Session Message With Window.location.href

window.location.href = '/plant_types/'+this.plant.id; How would I set the session variable so the page '/plant_types/'+this.plant.id' displays a flash('message'). In laravel controller I would normally use

Session::flash('success', 'Questions successfully updated!!'); 
return view('plant_types.show');
04 Feb
4 months ago

finchy70 started a new conversation Save Request $request To Different Records

I have a $request returned from a dynamically built form. Request $request

As you can see it has 5 different prefixes. oil_sample, trip_and_close, operations, panel_damage, cb_timing. I need to save each set of records with the same prefix to a single record in my answers table.

answers table

As you can see record 5 corresponds to the $requests with cb_timing prefix.

Can this be done?

finchy70 left a reply on Custom @include Directive To Fetch Correct View

My IDE PHPStorm doesn't like it either.

IDE Syntax Error

finchy70 left a reply on Custom @include Directive To Fetch Correct View

Yes variable is type1, and view is question_types/type1.blade.php.

finchy70 left a reply on Custom @include Directive To Fetch Correct View

And this error

syntax error, unexpected '<' (View: C:\Users\Paul\code\TxTest\resources\views\reports\show.blade.php)

finchy70 left a reply on Custom @include Directive To Fetch Correct View

Tried this.

 @include('question_types.' . {{$part->question->question_type->name}})

Didn't work.

finchy70 left a reply on Custom @include Directive To Fetch Correct View

I had tried that but get this error.

<?php echo $__env->make('question_types.' . <?php echo e($part->question->question_type->name); ?>, \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
syntax error, unexpected '<' (View: C:\Users\Paul\code\TxTest\resources\views\reports\show.blade.php)

finchy70 started a new conversation Custom @include Directive To Fetch Correct View

I want to fetch a specific view based on the following

@include('form_type.' {{$some->name}})

This wont work so tried a custom directive. Put this in my AppServiceProvider

 public function boot()
    {
       Blade::directive('formtype', function($expression) {
            return "<?php echo 'form_type.'{$expression}; ?>";
        });
    }

and this in my blade file

 @formtype({{$part->question->question_type->name}})

Still wont work. Is it possible to accomplish what I'm trying to do?

27 Jan
4 months ago

finchy70 left a reply on Laravel Is Still Displaying Old Welcome Screen

@Never had to do that before. Thank you.

26 Jan
4 months ago

finchy70 started a new conversation Laravel Is Still Displaying Old Welcome Screen

I have changed my welcome.blade.php file to extend layout.app and inserted some content. When I serve with php artisan serve Laravel keeps loading it's own standard welcome screen. I've done composer dump-autoload php artisan cache:clear, and I've even restarted my PC. My route file is pointig '/' to view 'welcome'. I know I've done something simple wrong but I cant figure it out. HELP!!!!

finchy70 left a reply on Eloquent Polymorphic DB Relationships

I have decided this is not the correct approach and have tried implement a different design pattern which will remove the need for separate models for each type of report.

09 Jan
5 months ago

finchy70 left a reply on Eloquent Polymorphic DB Relationships

Played around a little and added a type field to the plant table.

$table->string('type');

The type would contain a reference to the plants report model.

$plant->type = "App\AuxTxReport";

This simple function on the plant model

public function reports()
{
    return $this->hasMany($this->type);
}

Then accesses the correct table to retrieve reports.

Removes all the messy logic.

finchy70 left a reply on Eloquent Polymorphic DB Relationships

Was my plan to have one reports table but each plant type would require a different report with different fields. I have built this using multiple access relationships. One for transformer, one for Switchgear , and one for Generators.

public function generator_reports()
    {
        return $this->hasMany('App\GeneratorReport');
    }

public function aux_tx_reports()
    {
        return $this->hasMany('App\AuxTxReport');
    }

public function aux_tx_swg_reports()
    {
        return $this->hasMany('App\AuxTxSwitchgearReport');
    }

Logic such as

public function getCheckedByAttribute()
    {
        if($this->equipment_type_id === 1)
        {
            return $this->aux_tx_swg_reports()->orderBy('checked_at', 'desc')->first()->user->name;
        }
        elseif($this->equipment_type_id === 2)
        {
            return $this->aux_tx_reports()->orderBy('checked_at', 'desc')->first()->user->name;
        }   
        elseif($this->equipment_type_id === 4)
        {
            return $this->generator_reports()->orderBy('checked_at', 'desc')->first()->user->name;
        } 
        else
        {
            return null;
        }
    }

is used then to determine the relationship to use. All seems to messy and has a lot of repeated code.

finchy70 started a new conversation Eloquent Polymorphic DB Relationships

I have a DB which has a Plant table. This contains items of plant. They can be Transformers, Switchgears, or Generators. I then have a table for Switchgear Reports, a table for Transformer Reports, and a table for Generator Reports. I want to set up a porlymorphic relationship that supports a single plant object having multiple reports. These reports would all be of the same type dependant on whether the item is a transformer, switchgear, or generator. I want to set up relationships that when I ask for reports on an item it goes and gets them without me having to write logic to check the plant type then query the specific reports table. This would also mean adding new plant types and reports for that type would be a lot easier. I have tried to set up the polymorphic relationship on a test db with the report tables containing

            $table->morphs('reportable');

the Switchgear report table then contains this line in it model class.

public function plant()
    {
        return $this->morphTo(Plant::class, 'reportable');
    }

and the other report tables have the same. The plant model has this

 public function reportable()
    {
        return $this->morphMany();
    }

So what I want to know is polymorphic relationship the way to achieve what Im looking for and is my code to set up the relationships correct as it isn't working?

Regards Paul.

07 Jan
5 months ago

finchy70 left a reply on Using An Array Of Objects In A Form Drop Down

You can pass the $products to your view and the just loop through it.

Here is a simple example.

<select>
    @foreach($products as $item)
        <option value={{$item->id}}>{{$item->name}}></option>
    @endforeach
</select>

Hope this helps.

finchy70 started a new conversation Building An App To Use To Record Maintenance Reports

I'm building an app to record annual maintenance checks on electrical plant. The problem is each different type of plant (make/model) requires a different maintenance report. So what I need in to be able to create forms quickly, and associate them with a make/model. Each different item of plant also needs different information recorded dependant on make/model and the client. So first of all is there a package to allow the building of forms quickly maybe using a drag and drop ui in my applications admin panel and what would be the best database solution to store the non standard data as I don't want to build a new model for each report type. Any suggestions would be greatly appreciated.

18 Dec
6 months ago

finchy70 left a reply on Testing For Users With Unverified Emails.

@D9705996 - Exactly what I was after. Thanks.

finchy70 started a new conversation Testing For Users With Unverified Emails.

Ive used the following TestCase.php code with my Laravel tests. Recently I've added email verification and added the verifiy middleware to my controllers. I want to test that the current user signed in gets the email/verifiy page if his email_verified_at field is null.

Here is my TestCase.php with the code I've added to try to sign in the user with no email verification.

<?php

namespace Tests;
use Exception;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use App\Exceptions\Handler;
use Illuminate\Contracts\Debug\ExceptionHandler;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication;
    protected function setUp ()
    {
        parent::setUp();
        $this->user = factory('App\User')->create();
        $this->signIn($this->user)->disableExceptionHandling();
    }
    protected function disableExceptionHandling ()
    {
        $this->oldExceptionHandler = app()->make(ExceptionHandler::class);
        app()->instance(ExceptionHandler::class, new PassThroughHandler);
    }

    protected function withExceptionHandling ()
    {
        app()->instance(ExceptionHandler::class, $this->oldExceptionHandler);
        return $this;
    }

    protected function signIn($user)
    {
        $this->actingAs($user);
        return $this;
    }

    protected function signedInButNotVerified($user)
    {
        $user->email_verified_at = null;
        $this->actingAs($user);
        return $this;
    }

    protected function signOut()
    {
        $this->post('/logout');
        return $this;
    }


}
class PassThroughHandler extends Handler
{
    public function __construct () {}
    public function report (Exception $e) {}
    public function render ($request, Exception $e)
    {
        throw $e;
    }
}

My test is here

 /**
     * @test
     */
    public function it_cant_display_posts_if_user_not_verified()
    {
        $post = make('App\Post');

        $this->signInButNotVefified()->withExceptionHandling()->post('/posts', $post->toArray())
            ->assertRedirect('/email/verify');
    }

This does not work. How can I make the signed in user as unverified for certain tests?

07 Nov
7 months ago

finchy70 left a reply on All Tests Started Failing.

Thanks. I realised its due to me adding Voyager. The voyager migrations then break the tests. Not sure what to do with the migrations to stop the error so I decided to remove voyager and will reinstall it at the end of development I think.

finchy70 started a new conversation All Tests Started Failing.

I have 35 tests with 85 assertions that all were passing. The tests are done in an in memory database using DataBaseMigrations.

Every test now returns this error.

BadMethodCallException: SQLite doesn't support dropping foreign keys (you would need to re-create the table).

I have destroyed and re-upped my vagrant box (not that this would normally impact on in memory testing) but the errors still remain.

Also tried composer update.

Anyone else had this issue?

30 Oct
7 months ago

finchy70 left a reply on Tests Not Generating Id's.

@RyanSlicker You helped me notice I'd forgotten to return my helpers.

 create('App\Diary')->id;

should have been

return  create('App\Diary')->id;

finchy70 left a reply on Tests Not Generating Id's.

1) Tests\Feature\ResourceTest::it_can_display_resource_attached_to_a_diary_entry
Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: resources.labour_id (SQL: insert into "resources" ("labour_id", "resource_type_id", "diary_id", "hours", "works", "updated_at", "created_at") values (, , , 9.46, Est id accusamus ex adipisci sit autem atque id veritatis dolor., 2018-10-30 14:50:41, 2018-10-30 14:50:41))

finchy70 left a reply on Tests Not Generating Id's.

Yes heres one of them DiaryFactory

<?php

use Faker\Generator as Faker;

$factory->define(App\Diary::class, function (Faker $faker) {
    return [
        'user_id'        => function () {
            return create('App\User')->id;
        },
        'job_id'         => function () {
            return create('App\Job')->id;
        },
        'entry_date'     => $faker->date,
        'diary_entry' => $faker->sentence(25),
    ];
});

finchy70 started a new conversation Tests Not Generating Id's.

The following code is giving an error that suggests not values are being generated for 'diary_id', 'labour_id', 'resource_type_id'. I'm new to PHPUnit. Have I got my syntax wrong?

<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;


class ResourceTest extends TestCase
{
    use DatabaseMigrations;

    /**
     * @test
     */
    public function it_can_display_resource_attached_to_a_diary_entry()
    {
        $resource = create('App\Resource', [
            'diary_id'          => function() {
                create('App\Diary')->id;
            },

            'resource_type_id'  => function() {
                create('App\ResourceType')->id;
            },

            'labour_id'         => function() {
                create('App\Labour')->id;
            }]);

        dd($resource);

        $this->get('/diaries/entry/'.$resource->diary_id)
            ->assertSee(e($resource->labour->name));
    }
}
14 Sep
9 months ago

finchy70 left a reply on Difference Between Two Time Strings

This is working now. I was importing Carbon incorrectly.

13 Sep
9 months ago

finchy70 left a reply on Difference Between Two Time Strings

I'm struggling with handling times. I have used Carbon in the past but as I'm feeding a Vue component with return response and not returning a view dd() is not working and the errors produced by my component are not understandable. The resulting values with console logged show as invalid times.

finchy70 left a reply on Difference Between Two Time Strings

Tried this with no difference.

$start = DateTime($hours->start);
        $finish = DateTime($hours->finish);
        $hours->total = Carbon::parse($finish)->diffInMinutes(Carbon::parse($start));

finchy70 left a reply on Difference Between Two Time Strings

Can't dd. it has no effect. Just stops the controller saving the data.

finchy70 left a reply on Difference Between Two Time Strings

I had tried this previously but it throws a validation error in my coomponent.

Please correct the following error(s):
{ "config": { "transformRequest": {}, "transformResponse": {}, "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "headers": { "Accept": "application/json, text/plain, */*", "X-Requested-With": "XMLHttpRequest", "X-CSRF-TOKEN": "gBGZ7I8K3TXKxSiGOyuOefvgewhCzIc4zJO1y0H2", "Content-Type": "application/json;charset=utf-8", "X-XSRF-TOKEN": "eyJpdiI6IjhUNTIydTlQckluOWtcL0pmZU5ZK2RRPT0iLCJ2YWx1ZSI6ImVsenFnOCtzczBHT1g2b3BGeVdBQ3FSSHk4UmJ1UEthMURmWGhpOTFxekZJQ2JPVktQTXpyNWRWdCt2bGtKYzgiLCJtYWMiOiJhYjRkODFjOWVmMWZiZTI3NGJiZjVlOTBiZjRjOWE1ZTJkYzE2N2Y2MmE1MDAyNTJhMTU1ZDNiZTY0NWFlOTFmIn0=" }, "method": "post", "url": "/payroll", "data": "{\"employee_id\":\"1\",\"week_ending\":\"2018-07-29\",\"start\":\"02:30\",\"finish\":\"18:45\",\"job_number\":\"3\",\"climbing\":0,\"day\":\"Tuesday\",\"total\":null,\"period_id\":\"{\\"id\\":1,\\"period_week_ending\\":\\"2018-08-19\\",\\"weeks\\":4,\\"week1\\":\\"2018-07-29\\",\\"week2\\":\\"2018-08-05\\",\\"week3\\":\\"2018-08-12\\",\\"week4\\":\\"2018-08-19\\",\\"week5\\":null,\\"current\\":1,\\"created_at\\":\\"2018-09-13 10:03:03\\",\\"updated_at\\":\\"2018-09-13 10:03:03\\"}\"}" }, "request": {}, "response": { "data": { "message": "Object of class DateInterval could not be converted to string", "exception": "ErrorException", "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Support/Str.php", "line": 338, "trace": [ { "function": "handleError", "class": "Illuminate\Foundation\Bootstrap\HandleExceptions", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Support/Str.php", "line": 338, "function": "substr_replace" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Support/Str.php", "line": 315, "function": "replaceFirst", "class": "Illuminate\Support\Str", "type": "::" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/QueryException.php", "line": 56, "function": "replaceArray", "class": "Illuminate\Support\Str", "type": "::" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/QueryException.php", "line": 39, "function": "formatMessage", "class": "Illuminate\Database\QueryException", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Connection.php", "line": 665, "function": "__construct", "class": "Illuminate\Database\QueryException", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Connection.php", "line": 624, "function": "runQueryCallback", "class": "Illuminate\Database\Connection", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Connection.php", "line": 459, "function": "run", "class": "Illuminate\Database\Connection", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Connection.php", "line": 411, "function": "statement", "class": "Illuminate\Database\Connection", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php", "line": 32, "function": "insert", "class": "Illuminate\Database\Connection", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php", "line": 2494, "function": "processInsertGetId", "class": "Illuminate\Database\Query\Processors\Processor", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php", "line": 1283, "function": "insertGetId", "class": "Illuminate\Database\Query\Builder", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php", "line": 787, "function": "__call", "class": "Illuminate\Database\Eloquent\Builder", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php", "line": 752, "function": "insertAndSetId", "class": "Illuminate\Database\Eloquent\Model", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php", "line": 615, "function": "performInsert", "class": "Illuminate\Database\Eloquent\Model", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/app/Http/Controllers/PayrollController.php", "line": 47, "function": "save", "class": "Illuminate\Database\Eloquent\Model", "type": "->" }, { "function": "store", "class": "App\Http\Controllers\PayrollController", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Controller.php", "line": 54, "function": "call_user_func_array" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php", "line": 45, "function": "callAction", "class": "Illuminate\Routing\Controller", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 212, "function": "dispatch", "class": "Illuminate\Routing\ControllerDispatcher", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 169, "function": "runController", "class": "Illuminate\Routing\Route", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 665, "function": "run", "class": "Illuminate\Routing\Route", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php", "line": 41, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\Routing\Middleware\SubstituteBindings", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php", "line": 68, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\VerifyCsrfToken", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php", "line": 49, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\View\Middleware\ShareErrorsFromSession", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php", "line": 63, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\Session\Middleware\StartSession", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php", "line": 37, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php", "line": 66, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\Cookie\Middleware\EncryptCookies", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 104, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 667, "function": "then", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 642, "function": "runRouteWithinStack", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 608, "function": "runRoute", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 597, "function": "dispatchToRoute", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 176, "function": "dispatch", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "function": "Illuminate\Foundation\Http\{closure}", "class": "Illuminate\Foundation\Http\Kernel", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/fideloper/proxy/src/TrustProxies.php", "line": 57, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Fideloper\Proxy\TrustProxies", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 31, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 31, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php", "line": 27, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\ValidatePostSize", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php", "line": 62, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 151, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 104, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 151, "function": "then", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 116, "function": "sendRequestThroughRouter", "class": "Illuminate\Foundation\Http\Kernel", "type": "->" }, { "file": "/Users/paulfinch/Documents/GitHub/pay/public/index.php", "line": 55, "function": "handle", "class": "Illuminate\Foundation\Http\Kernel", "type": "->" }, { "file": "/Users/paulfinch/.composer/vendor/laravel/valet/server.php", "line": 147, "function": "require" } ] }, "status": 500, "statusText": "Internal Server Error", "headers": { "date": "Thu, 13 Sep 2018 12:07:06 GMT", "cache-control": "no-cache, private", "server": "nginx/1.15.3", "connection": "keep-alive", "x-powered-by": "PHP/7.2.9", "transfer-encoding": "chunked", "content-type": "application/json" }, "config": { "transformRequest": {}, "transformResponse": {}, "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "headers": { "Accept": "application/json, text/plain, */*", "X-Requested-With": "XMLHttpRequest", "X-CSRF-TOKEN": "gBGZ7I8K3TXKxSiGOyuOefvgewhCzIc4zJO1y0H2", "Content-Type": "application/json;charset=utf-8", "X-XSRF-TOKEN": "eyJpdiI6IjhUNTIydTlQckluOWtcL0pmZU5ZK2RRPT0iLCJ2YWx1ZSI6ImVsenFnOCtzczBHT1g2b3BGeVdBQ3FSSHk4UmJ1UEthMURmWGhpOTFxekZJQ2JPVktQTXpyNWRWdCt2bGtKYzgiLCJtYWMiOiJhYjRkODFjOWVmMWZiZTI3NGJiZjVlOTBiZjRjOWE1ZTJkYzE2N2Y2MmE1MDAyNTJhMTU1ZDNiZTY0NWFlOTFmIn0=" }, "method": "post", "url": "/payroll", "data": "{\"employee_id\":\"1\",\"week_ending\":\"2018-07-29\",\"start\":\"02:30\",\"finish\":\"18:45\",\"job_number\":\"3\",\"climbing\":0,\"day\":\"Tuesday\",\"total\":null,\"period_id\":\"{\\"id\\":1,\\"period_week_ending\\":\\"2018-08-19\\",\\"weeks\\":4,\\"week1\\":\\"2018-07-29\\",\\"week2\\":\\"2018-08-05\\",\\"week3\\":\\"2018-08-12\\",\\"week4\\":\\"2018-08-19\\",\\"week5\\":null,\\"current\\":1,\\"created_at\\":\\"2018-09-13 10:03:03\\",\\"updated_at\\":\\"2018-09-13 10:03:03\\"}\"}" }, "request": {} } }

finchy70 started a new conversation Difference Between Two Time Strings

A Vue component is sending 2 strings representing times to a Laravel controller using axios.

start "09:30:00" finish "14:30:00"

How do I get the time difference between $request->finish - $request->start?