theUnforgiven

theUnforgiven

Web Developer at NRS

Member Since 6 Years Ago

UK

Experience Points
308,800
Total
Experience

0 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
1784
Lessons
Completed
Best Reply Awards
45
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 50
308,800 XP
Nov
17
1 week ago
Activity icon

Replied to Notifications

Hmm, yeah good point. Maybe that will do the trick.

Activity icon

Started a new Conversation Notifications

Hi All,

I'm using the Laravel notifications and I've made some in realtime without the need to refresh etc using Pusher; however that's not the problem. The issue I'm facing is my client wants different types of notifications to be displayed in different boxes on their dashboard.

So with this in mind I hooked into the Notifications and came up with this:

//This is within User model

public function unreadTenantNotifications()
{
    return $this->morphMany(DatabaseNotification::class, "notifiable")
                ->where('notifiable_id', $this->id)
                ->where('type', 'App\Notifications\TenantPackCompleted')
                ->orWhere('type', 'App\Notifications\TenantCompletedAST')
                ->orWhere('type', 'App\Notifications\TenantPackNotCompleted')
                ->orWhere('type', 'App\Notifications\NotifyTenantOfRightToRentCheck')
                ->orWhere('type', 'App\Notifications\ConvertTempTenancy')
                ->orWhere('type', 'App\Notifications\FeedbackCompleted')
                ->orWhere('type', 'App\Notifications\TenantRegisteredFromInvite')
                ->orWhere('type', 'App\Notifications\TenantSignedUpForTap')
                ->whereNull('read_at');
}

Then in the blade file I just call

 {{ user()->unreadTenantNotifications()->count() }}

But seems the read_at isn't working and regardless of whether I've read it it still shows the number, sometimes doesn't even show the correct one.

What else can I do to get notifications of a certain type to be displayed to the current user and as not been read?

Nov
07
3 weeks ago
Activity icon

Replied to Mounting Stripe Elements, In Foreach Modal(s)

Ah, good point I guess, must have missed that. Anyhow I've gone a different route for now which will work just fine for what I need.

Activity icon

Replied to Mounting Stripe Elements, In Foreach Modal(s)

Hey @martinbean The modal is just in blade in a foreach loop and I've added the id of each loop item to the modal so that works fine, it was just adding the Stripe elements part that is my problem.

Activity icon

Replied to Mounting Stripe Elements, In Foreach Modal(s)

So, I guess my question is how to I mount the stripe element to each modal should there be more than one within the loop.

Activity icon

Started a new Conversation Mounting Stripe Elements, In Foreach Modal(s)

Hi all,

I have a foreach loop showing a list of "bills" and each one can have a Pay by Card link, which opens the Bootstrap modal window.

I need to show the Stripe Elements card div but it needs to relate to the current opened modal. I guess I can hook into the modal event, but I'm not sure how to, or what should I wrote to make this work. Can any of you wonderful people help me out?

This is the modal inside the foreach loop:

<!-- Modal -->
                            <div class="modal fade" id="item_{{$item->id}}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title" id="exampleModalLabel">Pay Bill</h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                        </button>
                                    </div>
                                    <div class="modal-body">
                                        <div class="bg-light p-3">
                                            
                                            <h4>Total (inc fees) {{ currency(card_fee($item->amount_outstanding)) }}</h4>
                                        </div>
                                        <div class="form-group">
                                            <label>Cardholder Name</label>
                                            <input id="card-holder-name" class="form-control" type="text">

                                            <!-- Stripe Elements Placeholder -->
                                            <div id="card-element"></div>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                        <button id="card-button" data-secret="{{ $intent->client_secret }}" class="btn btn-success">Pay Now</button>
                                    </div>
                                </div>
                            </div>
                            </div>

Then I have this JS, which does render in the first modal, but doesn't show in the other modals if there's more than one in the foreach loop.

<script>
    const stripe = Stripe('pk_test_xxxxxxxxxxxxxxx');
    const elements = stripe.elements();
    const cardElement = elements.create('card');

    cardElement.mount("#card-element");
</script>
Oct
26
1 month ago
Activity icon

Replied to How To Use Forked Repo In Composer....?

It;'s cool I figured it out you were right.

Activity icon

Replied to How To Use Forked Repo In Composer....?

No Gocardless is the originator, I've forked it already and made chanages, but I just can't get it to install in my Laravel project.

Activity icon

Replied to How To Use Forked Repo In Composer....?

See, I tried that and that didn't work just pulls in the original repo and not my fork

Activity icon

Replied to How To Use Forked Repo In Composer....?

So do I need to use the original repo with a "dev-" flag?

Activity icon

Replied to How To Use Forked Repo In Composer....?

So I forked a repo, made some changes on github direct and now I want to use that forked repo.

Activity icon

Started a new Conversation How To Use Forked Repo In Composer....?

Hi all,

I've forked a repo and made some changes, however I need to use my "fork" in the composer file to use my changes as I don't think the maintainer will do it by this week.

Question is how does one do this?

I have got:

"repositories": [
        {
            "type": "composer",
            "url": "https://nova.laravel.com",
            "options": {
                "symlink": false
            }
        },
        {
            "type": "vcs",
            "url": "[email protected]:username/package-name.git"
        }
    ],

But it's not pulling that forked repo in.

Oct
14
1 month ago
Activity icon

Replied to Leaderboard Rewards

Great idea @jeffreyway mugs, t-shirts, lifetime subscriptions all good for us still trying to get up the leader and also newcomers. Maybe something like reach level 25 get a mug, level 30 t-shirt and then increase the levels to maybe if you get 100 you get a lifetime subscription.

That way not everyone will reach but the likes of @bobbybouwmann @snapey might just get there as they are collectively helping us all learn and understand more and more each day.

Oct
09
1 month ago
Activity icon

Replied to Livewire. What Am I Missing....?

Ah that was changed 29 days ago according to Github so yeah that'll be it as I installed it a couple of days before then. So that would make sense.

I'm still going to install a fresh copy and see.

Activity icon

Replied to Livewire. What Am I Missing....?

It's Laravel Framework 8.0.1, so I'm guessing this was all addressed then. Maybe I'll do a fresh install and see if it was just my version outdated slightly.

Activity icon

Replied to Livewire. What Am I Missing....?

Commented out protected $namespace = 'App\Http\Controllers'; in RouteServiceProvider as Caleb shows in the v2 upgrade videos and renamed app.blade.php to app-layout.blade and now works.

Maybe this as been addressed in the latest version of Jetstream, but I'm using the version of when it was released.

Activity icon

Replied to Livewire. What Am I Missing....?

I'm using Jetstream and removing the layout doesn't show any styles now either.

Activity icon

Replied to Livewire. What Am I Missing....?

If I put back the render

Route::get('', [Tasks::class, 'render']);
    Route::get('create', [AddTask::class, 'render']);

The form shows but the styling is missing now. as app-layout is commented out.

Activity icon

Replied to Livewire. What Am I Missing....?

Imported at the top or web.php

use App\Http\Livewire\AddTask;
use App\Http\Livewire\Tasks;
use Illuminate\Support\Facades\Route;
Activity icon

Replied to Livewire. What Am I Missing....?

I still get Invalid route action: [App\Http\Controllers\App\Http\Livewire\Tasks].

When using:

Route::middleware(['verified'])->prefix('tasks')->group(function () {
    Route::get('', Tasks::class);
    Route::get('create', AddTask::class);
});
Activity icon

Replied to Livewire. What Am I Missing....?

Yes, i just wondered if it was the naming of it, so was toying around with different names but makes no difference the form doesn't get submitted at all.

Activity icon

Replied to Livewire. What Am I Missing....?

Yeah, I'll read up some more, thanks again buddy!

Activity icon

Replied to Livewire. What Am I Missing....?

Guess it's some JetStream stuff then, oh well nevermind I'll stick to what I know. Thanks for trying to help buddy :)

Activity icon

Replied to Livewire. What Am I Missing....?

The page and form are rendering, so I don't think that is the problem. Not sure what it is tbh

Activity icon

Replied to Livewire. What Am I Missing....?

Removing the layout and divs?

Activity icon

Replied to Livewire. What Am I Missing....?

use App\Http\Livewire\AddTask;
use App\Http\Livewire\Tasks;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});

Route::middleware(['verified'])->get('/dashboard', function () {
    return view('dashboard');
})->name('dashboard');


Route::middleware(['verified'])->prefix('tasks')->group(function () {
    Route::get('/', [Tasks::class, 'render']); // To show livewire classes...
    Route::get('create', AddTask::class);
});
Activity icon

Replied to Livewire. What Am I Missing....?

Still the same error, and I have it imported in the web.php file anyhow.

Activity icon

Replied to Livewire. What Am I Missing....?

Invalid route action: [App\Http\Controllers\App\Http\Livewire\AddTask] again I've tried changing routes and still nothing. I thought Livewire was suppose to be easy lol

Activity icon

Replied to Livewire. What Am I Missing....?

It is, that's the 1st thing I checked for :)

Activity icon

Replied to Livewire. What Am I Missing....?

Nope, the scripts and css are include with Jetstream on the layout

Activity icon

Replied to Livewire. What Am I Missing....?

When I created it via terminal:

 php artisan livewire:make AddTask
 COMPONENT CREATED  🤙

CLASS: app/Http/Livewire/AddTask.php
VIEW:  resources/views/livewire/add-task.blade.php

So I just presumed I could put all the html in that blade and would then look to the method called on the wire:submit

Activity icon

Replied to Livewire. What Am I Missing....?

add-task.blade.php in side of resources/views/livewire

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            Create task
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="shadow overflow-hidden sm:rounded-md">
             <form wire:submit.prevent="addTask">
                <div class="px-4 py-5 bg-white sm:p-6">
                    <div class="col-span-12 sm:col-span-6">
                        <x-jet-label for="current_password" value="Task" />
                        <x-form-input type="textarea" wire:model="task" class="mt-1 block w-full" />
                        @error('body') <span class="text-red-700">Task field is required</span> @enderror
                    </div>

                    <div class="col-span-12 sm:col-span-6 mt-2">
                        <x-jet-label for="current_password" value="Do you want alerting?" />
                        <div class="relative">
                            <select wire:model="alerts" class="mt-1 block appearance-none w-full border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500" id="grid-state">
                                <option value="">Please select</option>
                                <option>Yes</option>
                                <option>No</option>
                            </select>
                            <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
                            <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/></svg>
                            </div>
                        </div>
                        @error('alerts') <span class="text-red-700">Do you want an alert?</span> @enderror
                    </div>
                </div>

                <div class="flex items-center justify-end px-4 py-3 bg-gray-50 text-right sm:px-6">
                     <button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent text-sm leading-5 font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:shadow-outline-indigo active:bg-indigo-700 transition duration-150 ease-in-out">
                        Save
                    </button>
                </div>
                </form>
            </div>
        </div>
    </div>

</x-app-layout>

Activity icon

Replied to Livewire. What Am I Missing....?

It's all html in the livewire/add-task.blade.php

Activity icon

Replied to Livewire. What Am I Missing....?

I can see the form, it's not just submitting to the method on the class for some reason.

Activity icon

Replied to Livewire. What Am I Missing....?

<x-app-layout> is in the file as I'm using Jetstream

Activity icon

Started a new Conversation Livewire. What Am I Missing....?

Hi all,

Happy Friday!

I have a Jetstream install and have setup a couple of routes:

Route::middleware(['verified'])->prefix('tasks')->group(function () {
    Route::get('', [Tasks::class, 'render']);
    Route::get('create', [AddTask::class, 'render']);
});

Pointing to two different Livewire classes. So the index page showing tasks works and navigating to the create page works, however when trying to submit the form it doesn't work...So what am I missing?

class AddTask extends Component
{
    public $task = '';
    public $alerts = '';

    protected $rules = [
        'body' => 'required',
        'alerts' => 'required',
    ];

    public function render()
    {
        return view('livewire.add-task');
    }

    public function save()
    {
        dd('testing');
    }
}

Then the form I have:

<form wire:submit.prevent="save">
                <div class="px-4 py-5 bg-white sm:p-6">
                    <div class="col-span-12 sm:col-span-6">
                        <x-jet-label for="current_password" value="Task" />
                        <x-form-input type="textarea" wire:model="task" class="mt-1 block w-full" />
                        @error('body') <span class="text-red-700">Task field is required</span> @enderror
                    </div>

                    <div class="col-span-12 sm:col-span-6 mt-2">
                        <x-jet-label for="current_password" value="Do you want alerting?" />
                        <div class="relative">
                            <select wire:model="alerts" class="mt-1 block appearance-none w-full border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500" id="grid-state">
                                <option value="">Please select</option>
                                <option>Yes</option>
                                <option>No</option>
                            </select>
                            <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
                            <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/></svg>
                            </div>
                        </div>
                        @error('alerts') <span class="text-red-700">Do you want an alert?</span> @enderror
                    </div>
                </div>

                <div class="flex items-center justify-end px-4 py-3 bg-gray-50 text-right sm:px-6">
                     <button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent text-sm leading-5 font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:shadow-outline-indigo active:bg-indigo-700 transition duration-150 ease-in-out">
                        Save
                    </button>
                </div>
        </form>

Put it doesn't submit to see the dd() and just adds a ? to the end of the URL tasks/create?

What am I missing here?

Oct
02
1 month ago
Activity icon

Replied to Notifications Broadcasting In Realtime...

I have setup an event, so will I need to add this to each of the notification classes? So the $notifiable can be added as a param?

Activity icon

Replied to Notifications Broadcasting In Realtime...

Hmm, I guess you are right, just show un-read notifications I guess and Echo/Pusher will make that realtime.

Activity icon

Replied to Notifications Broadcasting In Realtime...

I do yes and the chat is using Laravel Echo and Vue also.

Activity icon

Replied to Notifications Broadcasting In Realtime...

Vue mainly, and I have a chat room setup so kinda figured it would be similar, but just not sure on the notifications and how to approach it.

Activity icon

Replied to Notifications Broadcasting In Realtime...

Anyone have any ideas suggestions on how best to approach this?

Oct
01
1 month ago
Activity icon

Started a new Conversation Notifications Broadcasting In Realtime...

Hi all,

I have a bunch of notification classes that I want to utilise using Pusher so that when a notification is added to the database it's displayed in realtime to the user receiving it. Kinda like a chat system but for notifications.

So I have an event that I want to call and pass the $notifiable variable to then the event can be responsible for distributing.

The way it currently works is you have to navigate away from a page or refresh to see any new notifications, how best can I do this with Pusher/Laravel Echo/Vue and also group the notifications by a specific type?

Any advice/suggestions, greatly appreciated.

Sep
24
2 months ago
Activity icon

Replied to Eloquent When Condition Question...

You were right, works a treat!

Activity icon

Replied to Eloquent When Condition Question...

Hmm, good point. I’ll have another look tomorrow now. Thank you 😉

Activity icon

Replied to Eloquent When Condition Question...

I tried multiple when methods and it didn’t like it

Activity icon

Replied to Eloquent When Condition Question...

Hmm, thanks I'll give that a try.

Activity icon

Replied to Eloquent When Condition Question...

@saurav77 But does that mean I would then need to replicate that for the others also?

Activity icon

Replied to Eloquent When Condition Question...

I've also tried methods like unless whenNotEmpty and still nothing....

So like I say a user could just filter by type, type and postcode and/or everything.

Activity icon

Started a new Conversation Eloquent When Condition Question...

Hi all,

I have the following code which seemed to work for the type but when I add more for postcode, bedrooms etc it doesn't then work.

$properties = Property::with('images')
            ->when($request->has('type'), function ($query) use ($request) {
                return $query->where('type', $request->get('type'));
            })
            ->when($request->has('postcode'), function ($query) use ($request) {
                return $query->where('postcode', $request->get('postcode'));
            })
            ->paginate(15);

So If I remove the postcode one it works, if i add it back it works on the type however if I try both type and postcode nothing returns, I've tried orWhere in the callback and still nothing.

This is what the filters look like and anyone of/and all of them could be filtered by the user.

Where am I going wrong?