Mick79

Mick79

Founder at SongBox

Member Since 2 Years Ago

Glasgow

Experience Points
12,370
Total
Experience

2,630 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
38
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 3
12,370 XP
Aug
06
3 days ago
Activity icon

Awarded Best Reply on Group By Month And Order By Something Else?

@rodrigo.pedra @jlrdw @marianomoreyra

I solved this really simply within the blade.

I changed

@foreach($groupedposts as $post)

to

@foreach($groupedposts->sortByDesc('post_likes') as $post)

And it's perfect.

Aug
05
4 days ago
Activity icon

Replied to Group By Month And Order By Something Else?

Yeah I did but still couldn't get it to work. I appreciate the help but I solved this as detailed above.

Activity icon

Replied to Group By Month And Order By Something Else?

@rodrigo.pedra @jlrdw @marianomoreyra

I solved this really simply within the blade.

I changed

@foreach($groupedposts as $post)

to

@foreach($groupedposts->sortByDesc('post_likes') as $post)

And it's perfect.

Activity icon

Replied to Group By Month And Order By Something Else?

I was excited by this solution (thank you) but I get this error message:

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'mvpfyi.posts.post_likes' which is not functionally dependent on columns in GROUP BY clause;

Aug
01
1 week ago
Activity icon

Started a new Conversation Integrate Old Laravel App Into New One.....

Sorry for the terrible title. Last year I wrote a great "community" app. Kinda like a forum, but that project never went anywhere.

I have something new which is good, but could benefit from a community section. Is there any way to integrate the old app with this one? I'm loathed at the thought of a massive copy and paste job.

I'm thinking along the lines of making the old app into a composer package, but I've never done that before. Am I thinking along the right lines?

Jul
28
1 week ago
Activity icon

Replied to Group By Month And Order By Something Else?

Ok I'll give it a bash, thanks. But I think it's the ordering within the month structure that's the thing which is breaking my soul.

Activity icon

Replied to Group By Month And Order By Something Else?

I get a "bad method call" error when I do that:

$posts = Post::query()
            ->get()
            ->groupBy(function ($date) {
                return Carbon::parse($date->created_at)->format('F');
            })->orderBy('created_at', 'DESC');
Activity icon

Replied to Group By Month And Order By Something Else?

PS - I've tried to edit this question to make the formatting better but the little humanity check thing is saying I haven't answered the question and I absolutely have.

Activity icon

Started a new Conversation Group By Month And Order By Something Else?

I'm stuck...

I have a series of posts that can be upvoted by my users. I require these posts to be grouped by month (as this is how I display them on the site) but within the month groups be ordered by "rank".

I thought I had it working with this:

$posts = Post::query()
            ->orderBy('post_likes', 'DESC')
            ->get()->groupBy(function ($date) {
                return Carbon::parse($date->created_at)->format('F');
            });

The above DOES allow me to display the posts by month but if a post in June has a higher score than a post in July then it goes to the top of the list.

This is what I need:

JULY

Post 1 - score 10 Post 2 - score 8 Post 3 - score 7

JUNE

Post 1 - score 20 Post 2 - score 13 Post 3 - score 7

Really stumped, any help appreciated.

May
15
2 months ago
Activity icon

Started a new Conversation Recommendations For The Best Way To Sort By Drag N Drop?

I have an app where folk upload music tracks. I need to allow them to drag and drop these tracks into the order they want them to display.

Any ideas or recommendations on the best way to do this? I was gonna go with just letting them manually type in a "1", "2", "3" etc. Would rather drag n drop but JS isn't my strong point.

I know I'll need to use JS but looking for any recommendations of packages or libraries etc that could be quick.

Thanks so much.

May
09
3 months ago
Activity icon

Replied to Checking For Logged In User On A Global Middleware

Legend. Been battling this for an hour.

Can't understand why it didn't work in the "middleware" section which is where the documentation tells you to put it if you want it to be global.

@lmartins

Mar
04
5 months ago
Activity icon

Replied to Can't Redirect From Within View Composer

Just got a chance to test it there. Yeah it works, however I'm going to knuckle down and write a middleware as this isn't maintainable - but for now it's the best solution. Thank you.

Activity icon

Started a new Conversation Can't Redirect From Within View Composer

So here's what I'm trying to achieve:

I want to show a "banner" at the top of every page on the site that says "your free trial ends in xx days".

My plan to achieve this is to use a view composer to get the user model and extract the "trial ends at" data.

This can then be passed to every view on the site and utilised to show the banner... easy... this part works.

However inside the view composer I want to check and see that IF the trial has expired then redirect to a payment page. Here's my view composer:

<?php

namespace App\Http\View\Composers;

use Auth;
use Carbon\Carbon;
use Illuminate\View\View;

class ProfileComposer
{

    public function compose(View $view)
    {
        if (Auth::check()) {
            $user = Auth::user();
            $trial = $user->trial_ends_at;

            if ($trial < Carbon::now()) {

                \Log::info("Inside the if...");
                return redirect('/time-to-pay');

            }

            $view->with('trial', $trial);
        }
        
    }
}

As you can see I'm logging out a debut statement inside that if statement and that IS being logged. So I am inside the statement but that return redirect is being ignored.

What am I doing wrong? Is there a better way to achieve the free trial check?

Thanks

Mar
02
5 months ago
Activity icon

Awarded Best Reply on Stripe Issue When Creating Subscription: "Could Not Determine Which URL To Request"

Thanks... sadly I tried that too and same problem.

I went to line 106 of resource API and logged out the $id value and it is null, not matter what I pass through at

$subscription->stripe_id

I have binned cashier and I'm now handling the web hooks with my own custom controllers.

Activity icon

Replied to Stripe Issue When Creating Subscription: "Could Not Determine Which URL To Request"

Thanks... sadly I tried that too and same problem.

I went to line 106 of resource API and logged out the $id value and it is null, not matter what I pass through at

$subscription->stripe_id

I have binned cashier and I'm now handling the web hooks with my own custom controllers.

Activity icon

Started a new Conversation Stripe Issue When Creating Subscription: "Could Not Determine Which URL To Request"

I've setup stripe multiple times and never had this issue before. I'm processing the "customer created" web hook and using the payload to attach stripe id to my user and setup a new subscription.

I'm getting the following error:

Stripe\Exception\UnexpectedValueException: Could not determine which URL to request: Stripe\Subscription instance has invalid ID:  in file /Users/mick/repos/askit/vendor/stripe/stripe-php/lib/ApiResource.php on line 107

This only happens when I try to create the new subscription. Here is my full controller:

public function handleCustomerCreated(Request $request)
    {
        $payload = json_decode($request->getContent(), true);

        $user_id = $payload->data->object->subscriptions->data[0]->metadata->user_id;
        $subscription_id = $payload->data->object->subscriptions->data[0]->id;
        $stripe_customer_id = $payload->data->object->id;
        $current_period_start = $payload->data->object->subscriptions->data[0]->current_period_start;
        $current_period_end = $payload->data->object->subscriptions->data[0]->current_period_end;
        $stripe_plan = $payload->data->object->subscriptions->data[0]->items->data[0]->plan->id;
        $name = $payload->data->object->subscriptions->data[0]->items->data[0]->plan->nickname;
        $stripe_status = $payload->data->object->subscriptions->data[0]->status;
        $interval = $payload->data->object->subscriptions->data[0]->items->data[0]->plan->interval_count;

        $user = User::query()->find($user_id);
        $user->stripe_id = $stripe_customer_id;
        $user->save();

        $subscription = new Subscription();
        $subscription->user_id = $user_id;
        $subscription->name = $name;
        $subscription->stripe_id = $stripe_customer_id;
        $subscription->stripe_status = $stripe_status;
        $subscription->stripe_plan = $stripe_plan;
        $subscription->interval = $interval;
        $subscription->current_period_start = $current_period_start;
        $subscription->current_period_end = $current_period_end;
        $subscription->subscription_id = $subscription_id;
        $subscription->save();

    }

If I remove the new Subscription stuff it works fine, the stripe is getting attached to my user model just fine. The error only happens on this part:

    $subscription = new Subscription();
        $subscription->user_id = $user_id;
        $subscription->name = $name;
        $subscription->stripe_id = $stripe_customer_id;
        $subscription->stripe_status = $stripe_status;
        $subscription->stripe_plan = $stripe_plan;
        $subscription->interval = $interval;
        $subscription->current_period_start = $current_period_start;
        $subscription->current_period_end = $current_period_end;
        $subscription->subscription_id = $subscription_id;
        $subscription->save();

Any ideas? The table was created automagically by Laravel Cashier.

Mar
01
5 months ago
Activity icon

Replied to Is Laravel Cashier Up To Date?

Thanks @bobbybouwmann - I had spent a while today making my own solution but I'm going to check this one it. It looks better than mine lol

Activity icon

Started a new Conversation Is Laravel Cashier Up To Date?

I've been utilising stripe checkout. The new version of it is awesome. Laravel cashier doesn't appear to handle the newer version of the web hooks.

From cashier docs

To ensure your application can handle Stripe webhooks, be sure to configure the webhook URL in the Stripe control panel. The full list of all webhooks you should configure in the Stripe control panel are:

customer.subscription.updated
customer.subscription.deleted
customer.updated
customer.deleted
invoice.payment_action_required

From Stripe Docs

Stripe sends the checkout.session.completed event when a Checkout payment is successful. 

I'm wondering if Cashier isn't meant to be used with Checkout? Would be a shame as the most recent version of Stripe Checkout is ridiculously great.

Feb
29
5 months ago
Activity icon

Started a new Conversation Why Does Laravel Use -> Instead Of Just A Dot?

It just occurred to me this evening that it's annoying having to use two keystrokes each time when a "dot" would be perfectly sufficient. I use C# in My day job and the dot notation there seems more natural.

Activity icon

Replied to Handling A Change Of User Email

Sorry I couldn't have been as clear as I thought. I was referring to the re-verification of a changed email. Not simply updating it.

Activity icon

Started a new Conversation Handling A Change Of User Email

Laravel's email verification is awesome. I'm wondering what folk's thoughts are on how to handle user changing / updating their email address.

Feb
28
5 months ago
Activity icon

Replied to ReferenceError: Can't Find Variable: $

Yeah

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

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

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

That is at the top of my < head >

Activity icon

Started a new Conversation ReferenceError: Can't Find Variable: $

I'm getting this error when I'm trying to include some jquery on a page

<script>
    $(document).ready(function () {
        $('.datepicker').pickadate();
    });
</script>

my bootstrap.js file has this

try {
    window.Popper = require('popper.js').default;
    window.$ = window.jQuery = require('jquery');

    require('bootstrap');
} catch (e) {}

HOWEVER.... if I include a CDN link to jQuery in the section of my site then it works.

Any idea why Laravel isn't pulling in jQuery correctly?

Activity icon

Replied to The Correct Way To Create Database Tables?

Ok that's cool. I'm actually glad to hear that, as that's the way I've been doing it for years.

Just checking.

Activity icon

Started a new Conversation The Correct Way To Create Database Tables?

Whenever I need a new table, or to amend a table I type

php artisan make:migration whatever

and then I go into that file and manually type

$table->string('whatever');

over and over... then migrate it.

Is this correct? I have limited experience of Symfony but I'm sure the migrations are created for you over there based on code you input to the model. Am I wrong?

Feb
26
5 months ago
Activity icon

Replied to Realtime Update With VUE

@alanholmes - I got this figured out man but I COULD NOT have done it without your help. Thanks so much. FYI this is the finished script that was required:

<script>

    export default {
        props: ['event'],
        data() {
            return {
                questions: this.event.questions,
            }
        },


        mounted() {
            console.log('Component mounted.');

            var pusher = new Pusher('*********************', {
                cluster: 'eu',
                forceTLS: true
            });

            const channel = pusher.subscribe('my-channel').bind('my-event', (data)  => {
                // this.questions = [ data.message, this.questions]
                this.questions.unshift(data.message)
            });

            // Enable pusher logging - don't include this in production
            Pusher.logToConsole = true;
        },

    }
</script>
Activity icon

Replied to Realtime Update With VUE

@alanholmes - I'm really sorry I just feel like a pest now... however...

Whenever I add

    data() {
            return {
                questions: event.questions,
            }
        },

I get this error in the console

[Vue warn]: Error in data(): "TypeError: Cannot read property 'questions' of undefined"

found in

---> <Questions> at resources/js/components/Questions.vue
       <Root>
warn @ app.js:30426
logError @ app.js:31685
globalHandleError @ app.js:31680
handleError @ app.js:31640
getData @ app.js:34539
initData @ app.js:34494
initState @ app.js:34433
Vue._init @ app.js:34792
VueComponent @ app.js:34939
createComponentInstanceForVnode @ app.js:33082
init @ app.js:32913
createComponent @ app.js:35765
createElm @ app.js:35712
createChildren @ app.js:35840
createElm @ app.js:35741
createChildren @ app.js:35840
createElm @ app.js:35741
createChildren @ app.js:35840
createElm @ app.js:35741
createChildren @ app.js:35840
createElm @ app.js:35741
patch @ app.js:36301
Vue._update @ app.js:33738
updateComponent @ app.js:33859
get @ app.js:34270
Watcher @ app.js:34259
mountComponent @ app.js:33866
./node_modules/vue/dist/vue.common.dev.js.Vue.$mount @ app.js:38836
./node_modules/vue/dist/vue.common.dev.js.Vue.$mount @ app.js:41736
Vue._init @ app.js:34804
Vue @ app.js:34870
./resources/js/app.js @ app.js:41871
__webpack_require__ @ app.js:20
0 @ app.js:42012
__webpack_require__ @ app.js:20
(anonymous) @ app.js:84
(anonymous) @ app.js:87
Show 7 more frames
app.js:31689 TypeError: Cannot read property 'questions' of undefined
    at VueComponent.data (app.js:1968)
    at getData (app.js:34537)
    at initData (app.js:34494)
    at initState (app.js:34433)
    at VueComponent.Vue._init (app.js:34792)
    at new VueComponent (app.js:34939)
    at createComponentInstanceForVnode (app.js:33082)
    at init (app.js:32913)
    at createComponent (app.js:35765)
    at createElm (app.js:35712)

:-(

Activity icon

Replied to Realtime Update With VUE

Ahh man I'm so grateful for your reply but it's still not working. Here's what the console is outputting

Pusher :  : ["Event recd",{"event":"my-event","channel":"my-channel","data":{"message":{"id":254,"created_at":"2020-02-26 11:45:06","updated_at":"2020-02-26 11:45:06","question":"rrr","question_token":"86523b16-5bd3-4a68-9a4b-a409839f5bec","user_id":null,"user_session":"e66fbcd9-564a-4338-82f1-1e5a93ac58c5","event_token":"0c17fb67-aede-402f-b16b-6bb3a78b43db","question_status":1,"answered":0}}}]

app.js:25735 Pusher :  : ["No callbacks on my-channel for my-event"]

and here is my full new component file with your changes

<template :key="componentKey">
    <div class="">
        <div class="card shadow mb-4" v-for="question in questions" :key="question.id">
            <div class="card-header gradient_bg d-flex justify-content-between align-items-center">
                <div class="">
                    {{question.created_at}}
                </div>
                <div class="">
                    <ul class="nav nav-pills card-header-pills float-right">
                        <li class="nav-item ml-2">
                            <a onclick="var result = confirm('Ban this user? All their questions will be deleted and the user will be blocked from posting any more.');"
                               class="btn bg-white nav-link " :href="'/ban-user/' + question.question_token"> <i
                                    class="fas fa-ban text-black-50"></i></a>
                        </li>
                        <li class="nav-item ml-2">
                            <a onclick="var result = confirm('Archive this question for later?');"
                               class="btn bg-white nav-link text-light"
                               :href="'/archive-question/' + question.question_token"> <i
                                    class="fas fa-archive text-black-50"></i></a>
                        </li>
                        <li class="nav-item ml-2">
                            <a onclick="var result = confirm('Are you sure you want to delete this question?');"
                               class="btn bg-white nav-link text-light"
                               :href="'/delete-question/' + question.question_token"> <i
                                    class="fas fa-trash-alt text-black-50"></i></a>
                        </li>
                        <li class="nav-item ml-2">
                            <a class=" btn bg-white text-light font-weight-bold  nav-link"
                               href="#"><i class="fas fa-star text-black-50"></i></a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="card-body p-3">
                <h5 class="card-title">{{question.question}}</h5>
                <div class="answer-area" style="display:none">
                    <form class="" method="POST" action="/add-answer/:question.question_token">
                        @csrf
                        <textarea rows="5" class="d-block w-100 mb-2 p-3" name="answer"></textarea>
                        <input type="submit" name="" class="btn btn-brand3 text-white fw900 px-5" value="Submit Answer"
                               placeholder="" :id="question.id">
                    </form>
                </div>
                <a href="#" :id="'answer-button' + question.id" class="btn btn-brand float-right px-5">Answer</a>
                <a href="#" id="close-button" style="display:none"
                   class="btn btn-danger text-white float-right px-5">Cancel</a>
            </div>
        </div>

    </div>

</template>


<script>
    export default {
        
        props: ['event'],

        data() {
            return {
                questions: event.questions,
            }
        },

        mounted() {
            console.log('Component mounted.');

            var pusher = new Pusher('*************', {
                cluster: 'eu',
                forceTLS: true
            });

            var channel = pusher.subscribe('my-channel').bind('my-event', function(data) {
                // assuming questions is an array
                this.questions.push(data.newQuestion);
            });

            // Enable pusher logging - don't include this in production
            Pusher.logToConsole = true;

        },

    }

</script>

Note that the IDE says

newQuestion

Is an unresolved variable.

Thank you so much. This has been killing me for days.

And don't know if this is relevant but "event" is a collection and "questions" is a relationship of "event".

Feb
25
5 months ago
Activity icon

Started a new Conversation Realtime Update With VUE

I have battled with VUE for a couple days now and I have what I need ALMOST complete but one thing eludes me; real time updating. I started this in another question but so much has changed since then that I want to start fresh.

WHAT I'VE ACHIEVED

  1. View component is setup and working within the blade as it should be
  2. I am able to push new data to the console in real time which means....
  3. My "Pusher" setup is correct

WHAT I CAN'T ACHIEVE

  1. Updating the collection with the new data that's been posted (but remember, this data IS making it to the page as I can print it to the console.

HERE'S WHAT I HAVE

VUE Component

<template>
    <div>

        <div class="card shadow mb-4"  v-for="question in event.questions">
            <div class="card-header gradient_bg d-flex justify-content-between align-items-center">
                <div class="">
                    {{question.created_at}}
                </div>
                <div class="">
                    <ul class="nav nav-pills card-header-pills float-right">
                        <li class="nav-item ml-2">
                            <a onclick="var result = confirm('Ban this user? All their questions will be deleted and the user will be blocked from posting any more.');" class="btn bg-white nav-link " :href="'/ban-user/' + question.question_token"> <i
                                    class="fas fa-ban text-black-50"></i></a>
                        </li>
                        <li class="nav-item ml-2">
                            <a onclick="var result = confirm('Archive this question for later?');" class="btn bg-white nav-link text-light" :href="'/archive-question/' + question.question_token"> <i
                                    class="fas fa-archive text-black-50"></i></a>
                        </li>
                        <li class="nav-item ml-2">
                            <a onclick="var result = confirm('Are you sure you want to delete this question?');" class="btn bg-white nav-link text-light" :href="'/delete-question/' + question.question_token"> <i
                                    class="fas fa-trash-alt text-black-50"></i></a>
                        </li>
                        <li class="nav-item ml-2">
                            <a class=" btn bg-white text-light font-weight-bold  nav-link"
                               href="#"><i class="fas fa-star text-black-50"></i></a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="card-body p-3">
                <h5 class="card-title">{{question.question}}</h5>
                <div class="answer-area" style="display:none">
                    <form class="" method="POST" action="/add-answer/:question.question_token">
                        @csrf
                        <textarea rows="5" class="d-block w-100 mb-2 p-3" name="answer"></textarea>
                        <input type="submit" name="" class="btn btn-brand3 text-white fw900 px-5" value="Submit Answer"
                               placeholder="" id="">
                    </form>
                </div>
                <a href="#" :id="'answer-button' + question.id" class="btn btn-brand float-right px-5">Answer</a>
                <a href="#" id="close-button" style="display:none"
                   class="btn btn-danger text-white float-right px-5">Cancel</a>
            </div>
        </div>



    </div>
</template>



<script>
    export default {
        props: ['event'],
        mounted() {
            console.log('Component mounted.');

            // Enable pusher logging - don't include this in production
            Pusher.logToConsole = true;

            var pusher = new Pusher('*************', {
                cluster: 'eu',
                forceTLS: true
            });

            var channel = pusher.subscribe('my-channel');
            channel.bind('my-event', function(data) {
                location.reload();
            });

        }
    }

    // $(document).ready(function () {
    //     $('#answer-button'+question.id).click(function () {
    //
    //         $('.answer-area'+question.id).show('slow');
    //         $('#answer-button'+question.id).hide();
    //         $('#close-button'+question.id).show();
    //     });
    //
    //     $('#close-button'+question.id).click(function () {
    //
    //         $('.answer-area'+question.id).hide('slow');
    //         $('#answer-button'+question.id).show();
    //         $('#close-button'+question.id).hide();
    //     });
    //
    // });
</script>

BLADE TEMPLATE

@extends('layouts.app')

@section('content')
    {{--    <meta http-equiv="Refresh" content="15">--}}
    <div class="container">
        <div class="row justify-content-center mb-4">
            <div class="col-12">

            </div>
        </div>

        <div class="row">
            <div class="col-12 col-md-4">
                <div class="card shadow mb-4">
                    <div class="card-header gradient_bg d-flex justify-content-between align-items-center">
                        <div class="">
                            <h5 class="card-text py-2">Event Details</h5>
                        </div>
                    </div>
                    <div class="card-body p-3">
                        <h3>{{$event->event_name}}</h3>
                    </div>
                </div>
            </div>
            <div class="col-12 col-md-8" id="questions">
                <questions :event="{{$event}}"></questions>

            </div>
        </div>
    </div>




@endsection

APP.JS


/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');

window.Vue = require('vue');

/**
 * The following block of code may be used to automatically register your
 * Vue components. It will recursively scan this directory for the Vue
 * components and automatically register them with their "basename".
 *
 * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
 */

// const files = require.context('./', true, /\.vue$/i)
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))

Vue.component('questions', require('./components/Questions.vue').default);

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

const app = new Vue({
    el: '#app',
});

I'd love to know what I'm missing. All help really appreciated.

Feb
24
5 months ago
Activity icon

Replied to Use PUSHER To Update Collection

Ok I'm getting..... somewhere.

Here is my blade template

<div class="row">
            <div class="col-12">
                <questions :event="{{$event}}"></questions>
            </div>
        </div>

and here is my vue component

<template>
   <p>{{ event.questions }}</p>
</template>

<script>
    export default {
       props: ['event'],
        mounted() {
            console.log('Component mounted.')
        }

    }
</script>

Everything is rendering on the page as I would want but NOT automatically. I need to manually refresh to see changes.

Feb
20
5 months ago
Activity icon

Replied to Use PUSHER To Update Collection

Some example code would be ridiculously amazing. I would be so grateful for that.

I mean.... my javascript isn't TERRIBLE... i just have found that going down the framework route has never been necessary for me. I can usually accomplish what I need with either some vanilla JS or jQuery.

I'm guessing the work I did last night on setting up the event listeners and broadcasters etc is still valid? Is it just how I put that info on the page that requires vue?

Activity icon

Replied to Use PUSHER To Update Collection

Thanks james. Javascript is my kryptonite but I've known for years I should buckle down and get Vue learned. It's probably not even gonna be that difficult. Ok that's on the cards for tonight. Thanks.

Feb
19
5 months ago
Activity icon

Started a new Conversation Use PUSHER To Update Collection

I'm using PUSHER and LARAVEL echo because I want to update a user dashboard in real time.

Right now it all "works" in that when a user takes an action (adds a question) then I get the dashboard of the other user (the question recipient) to DO SOMETHING.

By that I mean I can get it to show and alert or to refresh the page etc. so the thing is working.

What I can't seem to figure out or find any examples of anywhere is how to update the collection that is being shown on the page.

Basically the dashboard shows a list of questions (a collection from the DB). I want any new questions to appear without having to refresh the page (currently this is what I'm doing - refreshing the page - but it's a rubbish solution for various reasons).

Any ideas? Apologies for the clumsy question.

Feb
09
6 months ago
Activity icon

Replied to Get Difference Between Two Times In Hours Or Minutes

Thanks, this works.

I had to change "60" to "1" because we're searching in hours and you left of a ")" :-)

But all good!

Thank you.

Activity icon

Replied to Get Difference Between Two Times In Hours Or Minutes

Hmm.. can you use carbon parsing in an eloquent statement?

$currentPeriodCookEngagement = Shift::query()
            ->where([
                ['created_at', '>=', $periodStart],
                ['created_at', '<=', $periodEnd],
        ['start_time'->diffInHours('stop_time')]
            ])->distinct()->count('cook_id');
Activity icon

Started a new Conversation Get Difference Between Two Times In Hours Or Minutes

I need to pull something out of the database WHERE the difference between "start_time" and "stop_time" is greater than an hour.

In sql it seems I can use "timediff" but how can I do this with Eloquent. What I want is something like this

$currentPeriodCookEngagement = Shift::query()
            ->where([
                ['created_at', '>=', $periodStart],
                ['created_at', '<=', $periodEnd],
        [('stop_time','-','start_time') > 60]
            ])->distinct()->count('cook_id');

Any ideas?