theUnforgiven

theUnforgiven

Web Developer at NRS

Member Since 6 Years Ago

UK

Experience Points
298,510
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
1707
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
298,510 XP
Jul
12
1 day ago
Activity icon

Replied to Get Users Via Pivot

Then also a user can have a tenancy and that tenancy have a property all of which have a relation in some respect. So its like have 3/4 tables all related.

Activity icon

Replied to Get Users Via Pivot

I think a hasManyThrough would be the answer, just unsure to how and what I need to reference based on my tables.

Activity icon

Started a new Conversation Get Users Via Pivot

Hi all,

Hope everyone is having a good weekend.

I'm not sure how to achieve the following, so help greatly appreciated.

I have a Users table & a Companies table, these are related by a company_user pivot table which houses the company_id and user_id.

I need to get the relationship(s) from the company ,but that company could be a parent and/or belong to another parent, and both parents can have children, plus I only want to get a specific type, based on the account_type from the user's table (i.e tenants).

How is this possible and what can I do to achieve such complex relationships?

Thanks in advanced.

Jul
08
5 days ago
Activity icon

Replied to Dates In For Loop Issue!

Damn! Yeah why not (smacks head and buries in ground)

Activity icon

Started a new Conversation Dates In For Loop Issue!

If I specify the start date as 2020-07-01 I want that to go in the loop also, and then finish the loop when it hits the end date given, say in 6 months time..

for ($i = 0; $i <= $duration; $i++) {
    Commitment::create([
        'user_id' => 270,
        'tenancy_id' => 108,
        'dates' => $i == $duration ? $end->toDateString() : $start->addMonths($i)->toDateString()
    ]);
}

here's what I extracted from the db as JSON, so right in the sense, but would need to also add the start date one too.

[
  {
    "id": 127,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-08-01 00:00:00",
    "month": 0
  },
  {
    "id": 128,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-09-01 00:00:00",
    "month": 0
  },
  {
    "id": 129,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-10-01 00:00:00",
    "month": 0
  },
  {
    "id": 130,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-11-01 00:00:00",
    "month": 0
  },
  {
    "id": 131,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-12-01 00:00:00",
    "month": 0
  }
]
Activity icon

Replied to Date Incrementing Based On Given Date

Does anyone have any more suggestions on how I achieve such task please :)

Jul
07
6 days ago
Activity icon

Replied to Date Incrementing Based On Given Date

Although this seemed right at the time, it's actually not:

If I specify the start date as 2020-07-01 I want that to go in the loop also, and then finish the loop when it hits the end date given, say in 6 months time..

here's what I extracted from the db as JSON, so right in the sense, but would need to also add the start date one too.

[
  {
    "id": 127,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-08-01 00:00:00",
    "month": 0
  },
  {
    "id": 128,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-09-01 00:00:00",
    "month": 0
  },
  {
    "id": 129,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-10-01 00:00:00",
    "month": 0
  },
  {
    "id": 130,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-11-01 00:00:00",
    "month": 0
  },
  {
    "id": 131,
    "user_id": 129,
    "tenancy_id": 59,
    "dates": "2020-12-01 00:00:00",
    "month": 0
  }
]
Jul
02
1 week ago
Activity icon

Replied to Sending To Other ID Within One Column...[Assistance]

@frankielee I believe this was you. Feel free to say so and I can give you credit for it.

Activity icon

Replied to Sending To Other ID Within One Column...[Assistance]

$re = Feedback::where('recipient_id', '!=', user()->id)->pluck('recipient_id')->first();
$user = User::where('id', $re)->first();
$user->notify((new FeedbackCompleted($feedback))->delay($when));

Works a treat, someone did post a similar solution, but for some reason it's not displayed but I got the email.

Activity icon

Started a new Conversation Sending To Other ID Within One Column...[Assistance]

Hi all,

I'm sure there's a way to do this, but can't for the life of me think what/how.

I have a bunch of different IDs in a recipient column within the database.

I want to send a notification to the other party, so if logged in user is 143 then I want to be able to send the notification to 270 and vice versa. How can this be done with ease...?

Jun
27
2 weeks ago
Activity icon

Commented on Transitions 101

@JeffreyWay - Are you planning on showing us how to use Alpine for a reusable Modal window?

Jun
25
2 weeks ago
Activity icon

Replied to Livewire Help Relationships

Scratch that....figured it out...

I was using factories to seed the database and there was some ID's that didn;'t tally up...omg it's been a long hot day here in the UK, forgive me :)

Activity icon

Started a new Conversation Livewire Help Relationships

Hi all,

I have the following code in my Livewire component:

$tasks = Tasks::with('user')->where('owner_id', auth()->user()->id)->get();

        foreach($tasks as $task) {
            dd($task->user->name);
        }

dd($task->user->name); shows the user's name, however....

Comment that out and do:

 return view('livewire.tasks.all', [
            'tasks' => Tasks::with('user')->where('owner_id', auth()->user()->id)->paginate(10),
        ]);

Then within my view file I have the foreach:

@foreach($tasks as $task)
	<p>{{ $task->user->name }}</p>
@endforeach

Which shows as a Trying to get property 'name' of non-object any reason why this would be?

Also I have the relationships setup on each the Task and User models.

//User Model

 public function tasks()
    {
        return $this->hasMany(Tasks::class, 'task_owner');
    }


// Task Model

public function user()
    {
        return $this->belongsTo(User::class, 'task_owner');
    }
Jun
24
2 weeks ago
Activity icon

Replied to Using JS (Vue) In Larvel To Toggle Hamburger Button

Also make sure you have run npm run dev to compile the changes you make and to register the component, if you haven't already.

Activity icon

Replied to Using JS (Vue) In Larvel To Toggle Hamburger Button

Just call the component within your blade file like so:

<menu />

Unless you want to pass something inside then it would be:

<menu>something inside, i.e links otherwise pass props.</menu>
Activity icon

Replied to Date Incrementing Based On Given Date

Sweet, yeh thats it, thank you very much @michaloravec

Activity icon

Started a new Conversation Date Incrementing Based On Given Date

Hi all,

I hope everyone is well & healthy.

I have a small issue, I can't seem to get my around.

Just bashing this out in Tinkerwell for quickness, but it's doing as I want.

$duration = 12;
$start = '2020-06-05';
$end = '2021-06-04';
$diff_in_months = diffInMonths($start,$end);
$date = Carbon\Carbon::now()->addMonth();


for ($i = 0; $i <= $duration; $i++) {
    return Commitment::create([
        'user_id' => 270,
        'tenancy_id' => 108,
        'dates' => $date // This is what I'm struggling with...
    ]);
}

So for each records it should be 12 records or whatever is within the duration, but the dates attribute in the create method should be from the start date and increment the months to the end date. So how would one achieve this so there would be 12 records in the db starting from 2020-06-05 then next record would be 2020-07-05 then 2020-08-05 and so on until the end date of 2021-06-04 in this example.

Thanks in advance and I hope one of you lovely people can help me...

Jun
09
1 month ago
Activity icon

Replied to Quick Vue Question (hopefully)

Yeah decent chocolate too

Activity icon

Replied to Quick Vue Question (hopefully)

Metallica and Maiden lol

Activity icon

Replied to Quick Vue Question (hopefully)

Yes I took your advice and done it from the backend, all is good now and I have more control now.

Jun
08
1 month ago
Activity icon

Replied to Quick Vue Question (hopefully)

9/10 I do from database/backend just in this instance I didn't and don't know why I did it this way, probably just for quickness to get it up and running I guess. But no is the time to change and update it.

Activity icon

Started a new Conversation Quick Vue Question (hopefully)

Hi all, Happy Monday :)

I have a select field

Which is rendered from Vue like so:

<div class="form-group">
                  <label>Select number</label>
                  <select class="form-control" v-model="numberSelection" @change="createBlock" ref="blockSelection">
                  		<option selected="" value="Please Select">Please Select a Block</option>
						<option v-for="item in blockNumber" :value="item" :key="item" :data-url-desc="numberSelection">
						Block {{ item }}
						</option>
                  </select>
              </div>

// Then in the mounted method I get the list from the prop that's passed.

for(let i = 0; i <  this.blocks.number_of_blocks; i++) {
	this.blockNumber = i+1;
}

This gives me what you see in the screen shot, however I want to show within the select only items not flagged as complete which in my database I have an complete column.

My question is how can I do this?

Jun
07
1 month ago
Activity icon

Awarded Best Reply on Livewire/Alpine Modal How To Close Upon Successfully Posting..?

After a quick convo on twitter , I found I needed to do the following:

$this->dispatchBrowserEvent('close-modal');

then on the x-data do :

x-on:close-modal.window="on = false"
Activity icon

Replied to Livewire/Alpine Modal How To Close Upon Successfully Posting..?

After a quick convo on twitter , I found I needed to do the following:

$this->dispatchBrowserEvent('close-modal');

then on the x-data do :

x-on:close-modal.window="on = false"
Activity icon

Replied to Livewire/Alpine Modal How To Close Upon Successfully Posting..?

Yeah, that's what I thought, but I tried what's in the docs and it doesn't show as fired.

Activity icon

Replied to Livewire/Alpine Modal How To Close Upon Successfully Posting..?

When the component renders the modal isn't shown, I use the click event handler to initialise it and show it, but upon filling the form out I want to close it. I understand with Bootstrap this is staright forward, but i'm using Tailwind, Alpine and Livewire, well trying to ;)

Activity icon

Replied to Livewire/Alpine Modal How To Close Upon Successfully Posting..?

It's ok buddy, I was confused at first. I just can't figure out how to close the modal.

The 2nd block of code I put starting <div> <x-modal title="Add task">... is the Livewire blade file.

The last block of code is the <x-modal> laravel component.

Activity icon

Replied to Livewire/Alpine Modal How To Close Upon Successfully Posting..?

The submit does call the Livewire component as the data saves, I just can't figure out how to close the modal at that point.

Activity icon

Started a new Conversation Livewire/Alpine Modal How To Close Upon Successfully Posting..?

Hi all,

I have a Livewire component:

class AddTask extends Component
{
    public $name;
    public $due_date;
    public $assigned_to;
    public $calendar;
    public $description;

    public function addTask()
    {
        $this->validate([
            'name'          => 'required|min:3',
            // 'due_date'      => 'required',
            'assigned_to'   => 'required',
            'calendar'      => 'required'
        ]);

        Tasks::create([
            'user_id' => user()->id,
            'name' => $this->name,         
            'due_date' => $this->due_date,       
            'assigned_to' => 1,  
            'calendar' => $this->calendar,
            'description' => $this->description      
        ]);
     
    
        session()->flash('success', 'Setup now complete.');
        return back();
    }
    public function render()
    {
        return view('livewire.tasks.add-task');
    }
}

I then have this in a blade file which calls a Laravel component

<div>
    <x-modal title="Add task">
        <x-slot name="trigger">
            <button class="text-xs bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Add New Task</button>
        </x-slot>
        <form>
            <div class="flex w-full sm:content-center flex-wrap mb-6">
                <label for="name" class="block text-gray-700 text-sm font-bold mb-2">
                    {{ __('Name') }}
                </label>

                <input wire:model="name" id="name" type="text" class="form-input w-full @error('name') border-red-500 @enderror" value="{{ old('name') }}">

                @error('name')
                    <p class="text-red-500 text-xs italic mt-4">
                        {{ $message }}
                    </p>
                @enderror
            </div>
            <x-slot name="submit">
                <button type="submit"
                        wire:click="addTask"
                        class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 bg-teal-600 text-base leading-6 font-medium text-white shadow-sm hover:bg-teal-500 focus:outline-none focus:border-teal-700 focus:shadow-outline-teal transition ease-in-out duration-150 sm:text-sm sm:leading-5"
                >
                Add Task
                </button>
            </x-slot>
        </form>
    </x-modal>
</div>

x-model component, just standard stuff with Tailwind and AlpineJS

<div x-data="{ on: false }">
    <span @click="on = true">{{ $trigger }}</span>

    <div class="fixed bottom-0 inset-x-0 px-4 pb-4 sm:inset-0 sm:flex sm:items-center sm:justify-center" x-show="on">
      <div
          class="fixed inset-0 transition-opacity"
          x-show="on"
          x-transition:enter="ease-out duration-300"
          x-transition:enter-start="opacity-0"
          x-transition:enter-end="opacity-100"
          x-transition:leave="ease-in duration-200"
          x-transition:leave-start="opacity-100"
          x-transition:leave-end="opacity-0"
      >
        <div class="absolute inset-0 bg-gray-500 opacity-75"></div>
      </div>

      <div class="bg-white rounded-lg overflow-hidden shadow-xl transform transition-all sm:max-w-lg sm:w-full"
           role="dialog"
           aria-modal="true"
           aria-labelledby="modal-headline"
           x-show="on"
           x-transition:enter="ease-out duration-300"
           x-transition:enter-start="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
           x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
           x-transition:leave="ease-in duration-200"
           x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
           x-transition:leave-end="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
      >
        <div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
          <div class="sm:flex sm:items-start">
            
            <div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full">
              <h3 class="text-lg leading-6 font-medium text-gray-900"
                  id="modal-headline"
              >
                {{ $title ?? '' }}
              </h3>
              <div class="mt-2">
                <p class="text-sm leading-5 text-gray-500">
                  {{ $slot }}
                </p>
              </div>
            </div>
          </div>
        </div>

        <div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
          <span class="flex w-full rounded-md shadow-sm sm:ml-3 sm:w-auto">
            {{ $submit }}
          </span>
          <span class="mt-3 flex w-full rounded-md shadow-sm sm:mt-0 sm:w-auto">
            <button type="button"
                    @click="on = false"
                    class="inline-flex justify-center w-full rounded-md border border-gray-300 px-4 py-2 bg-white text-base leading-6 font-medium text-gray-700 shadow-sm hover:text-gray-500 focus:outline-none focus:border-blue-300 focus:shadow-outline-blue transition ease-in-out duration-150 sm:text-sm sm:leading-5"
            >
              {{ $cancelLabel ?? 'Cancel' }}
            </button>
          </span>
        </div>
    </div>
</div>

</div>

My question is within the Livewire component just before this takes place

session()->flash('success', 'Setup now complete.');
return back();

How would I fire off the event to close the modal window and show the flash message? What do I need javascript wise and what should be called in the Livewire component?

Jun
02
1 month ago
Activity icon

Awarded Best Reply on VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Yeah and just put isTyping back and changed to arrow function and that all works now, so just need to figure out the name issue.

Thank you greatly both @bryank & @mkshingrakhiya

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

I can't give a best solution as you were both helpful.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Yeah and just put isTyping back and changed to arrow function and that all works now, so just need to figure out the name issue.

Thank you greatly both @bryank & @mkshingrakhiya

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

The message does show on the other users account, however the name does not

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

The typing indicator can be sorted afterwards, just need to get the name displaying when the message as been sent, so I commneted out the isTyping for now to remove that error I sent.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Which is

isTyping() {
            let channel = Echo.private('groups.' + this.group.id);

            setTimeout(function() {
                channel.whisper('typing', {
                user: this.currentUser.name, // THIS LINE
                    typing: true
                });
            }, 300);
        },
Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

@mkshingrakhiya

Uncaught TypeError: Cannot read property 'name' of undefined
    at laravel.app.js:14949
Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

@bryank In pusher is does state Channel: private-groups.2, Event: NewMessage

@mkshingrakhiya Log what to the console?

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

In pusher it shows as:

{
  "message": "hi there",
  "user": {
    "name": "jhg wertyu"
  },
  "date": "2020-06-02T14:55:40.000000Z"
}
Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

@mkshingrakhiya Moving to just Broadcast::routes(); seems to have worked and shows the message on the other user now in realtime, however the name of the user that sent it, isn't been displayed.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

I do see, this

that;'s the only error

Which looks like it's user: this.currentUser.name, within the whisper function

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

@bryank No, all I see is the actual axios post of the new message and within Pusher the API messages as I previously posted.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

public function boot()
    {
       Broadcast::routes(['middleware' => ['auth:api']]);

        require base_path('routes/channels.php');
    }
Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Just doesn't make any sense as to why the message isn't been broadcast to the other user

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Doesn't look like it's made any difference.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Looking at the $data on the broadcasting/auth this is all I see

{
"socket_id": "128551.16249636",
"channel_name": "private-groups.2"
}
Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

There isn't a join function, this is all setup from creating a group where both users are added.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

I need to work out what's in data as dump and dd isn't doing anything nor am I seeing it within the network tab