Jakub003

Member Since 6 Months Ago

Experience Points
9,460
Total
Experience

540 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
85
Lessons
Completed
Best Reply Awards
0
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.

  • Community Pillar

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

Level 2
9,460 XP
May
03
3 days ago
Activity icon

Awarded Best Reply on Is There A Way To Set Values With Wire:click?

I got this working with setting the value for the icon with php for each hard coded value.

enter image description here

Than the livewire function looks like

public function updateTagIcon($id,$icon)
    {
        $this->icon = $icon;
    
        $this->validate([
            'icon' => 'required',
        ]);

        $this->tag->update(['icon' => $this->icon]);

        $this->tag=Tag::find($this->tag->id);

    }
Activity icon

Replied to Is There A Way To Set Values With Wire:click?

I got this working with setting the value for the icon with php for each hard coded value.

enter image description here

Than the livewire function looks like

public function updateTagIcon($id,$icon)
    {
        $this->icon = $icon;
    
        $this->validate([
            'icon' => 'required',
        ]);

        $this->tag->update(['icon' => $this->icon]);

        $this->tag=Tag::find($this->tag->id);

    }
Activity icon

Started a new Conversation Is There A Way To Set Values With Wire:click?

I am trying to create a custom dropdown to change the icon of a button with alpinejs since I can't have icons or styling with the default select and options html

enter image description here

This is the livewire code to update icon

public function updateTagIcon($id,$value)
    {
        $this->icon = $value;

        $this->validate([
            'icon' => 'required',
        ]);

        $this->tag->update(['icon' => $this->icon]);

        $this->tag=Tag::find($this->tag->id);

    }

Is there a way I can do @click with alpineJS to set $value=1 and pass that to livewire?

Or maybe there is a way to arbitrarly set this data with wire:click?

<div wire:click="updateTagIcon({{$tag->id}},'{{$value=2}}')">
  <button type="button">
     <svg> //</svg>       
     {{$tag->title}}           
  </button>   
</div>

Was thinking maybe to emit an event with alpine @click but still not sure how I would pass a value to update the $icon in livewire

Activity icon

Replied to Livewire Sortable Group Eloquent Query?

I just learned that this can't be done with livewire sortable >.<

Sorry for all the confusion

Apr
22
2 weeks ago
Activity icon

Replied to Livewire Sortable Group Eloquent Query?

I am new to coding, and eloquent queries are a bit over my head still.

That is essentially my question, how do I set up the update function to pass both the order and column_id?

Apr
16
2 weeks ago
Activity icon

Replied to Livewire Sortable Group Eloquent Query?

Yea that is the part I am lost on.

How would I write the function so that it updates 2 values at the same time. One which would be what order a card is in a given column, and the second value being what column it is in?

I was able to get this far to make this work with a single dimension thing.


 public function updateTaskOrder($tasks)
    {
        foreach($tasks as $task) {
            Task::find($task['value'])->update(['order' => $task['order']]);
        }

    
    }

How do you also update the column the task is in as well?

Apr
12
3 weeks ago
Activity icon

Started a new Conversation Livewire Sortable Group Eloquent Query?

This is probably a huge newb question, but I can't seem to find any tutorials or examples for how to write out the livewire public function to make the group thing work. Any links to a guide would be much appreciated as well :)

In this documentation https://github.com/livewire/sortable there is only an example of the blade view. I was able to find how to make the sortable work in some demos for a single item.

To drag around the order of some subtasks, I did this. Since only one column value needs to be changed, I kinda understand this eloquent query... I am really lost on how this is supposed to work to drag and drop cards between columns like on trello.

public function updateCardTaskOrder($cardtasks)
    {
        foreach($cardtasks as $cardtask) {
            Cardtask::find($cardtask['value'])->update(['order' => $cardtask['order']]);
        }

        $this->cardtasks = Cardtask::where('card_id', $this->card_id)
            ->orderBy('order', 'ASC')
            ->get();
    
    }

Q1. How would I change the public function to update the order along with the column_id?

Q2. I think I setup the group thing right?

<div wire:sortable="updateColumnOrder" wire:sortable-column="updateTaskOrder">
    @foreach ($columns as $column)
        <div wire:key="column-{{ $column->id }}" wire:sortable.item="{{ $column->id }}">

            <ul wire:sortable-column.item-column="{{ $column->id }}">
                @foreach ($tasks as $task)
                    <li wire:key="task-{{ $task->id }}" wire:sortable-column.item="{{ $task->id }}">
                          // Show card stuff
                    </li>
                @endforeach
            </ul>
            
        </div>
    @endforeach
</div>

enter image description here

Any advice in general is much appreciated regarding this :)

Apr
09
3 weeks ago
Activity icon

Awarded Best Reply on Passing ID From Blade To Model Not Working?

I think so? I would like to make each card a unique object if I am using the correct terms. So that I could enable inline editing of titles, adding tags ect to them.

I rewatched the livewire screencasts on the official site today, I think I may know how todo this now using mount and grabbing the ID that way. Will try it tomorrow, and post the solution if I get it right.

I was able to do a similar thing with the sidebar navigation for the kanban

@foreach ($kanbans as $kanban )
        @livewire('kanbans.show-sidebar-kanban', ['kanban'=>$kanban], key($kanban->id))
@endforeach
public function mount(Kanban $kanban)
    {
        $this->kanban = $kanban;

        $this->kanban_id = $kanban->id;
       
        $this->refreshPages();
    }

Seems to be like I am redoing this app each day as I discover a new issue hahaha

Mar
31
1 month ago
Activity icon

Replied to Passing ID From Blade To Model Not Working?

I think so? I would like to make each card a unique object if I am using the correct terms. So that I could enable inline editing of titles, adding tags ect to them.

I rewatched the livewire screencasts on the official site today, I think I may know how todo this now using mount and grabbing the ID that way. Will try it tomorrow, and post the solution if I get it right.

I was able to do a similar thing with the sidebar navigation for the kanban

@foreach ($kanbans as $kanban )
        @livewire('kanbans.show-sidebar-kanban', ['kanban'=>$kanban], key($kanban->id))
@endforeach
public function mount(Kanban $kanban)
    {
        $this->kanban = $kanban;

        $this->kanban_id = $kanban->id;
       
        $this->refreshPages();
    }

Seems to be like I am redoing this app each day as I discover a new issue hahaha

Mar
30
1 month ago
Activity icon

Replied to Passing ID From Blade To Model Not Working?

Not exactly sure what you want me to post, but I think its this?

Route::get('/team/kanban/{kanban}/{page}/show', [KanbanController::class, 'show'])->name('kanbans.show');

KanbanController

 public function show($kanban, $page)
    {
        $kanban = Kanban::where('id', $kanban)->firstOrFail();
        $page = Page::where('id', $page)->firstOrFail();
        
        return view('kanbans.view-page-tasks',compact('kanban','page'));
    }

The URL in the browser for the page is

http://oneprojectbeta.test/team/kanban/1/1/show

In the URL the 1 is present for the page id. Is there a way to just grab it from URL?

Activity icon

Replied to Passing ID From Blade To Model Not Working?

I am getting this error when I try that now.

enter image description here

@foreach ($column->tasksOnPage($page->id)->get() as $card )
  @include('kanbans.show-card')
@endforeach

This is my column model if it helps

class Column extends Model
{
    use HasFactory;

    protected $fillable = [
        'kanban_id',
        'icon',
        'color',
        'title',
        'order',
    ];

    public function kanban()
    {
        return $this->belongsTo(Kanban::class);
    }

    public function cards(){
        return $this->hasMany('App\Models\Card');
    }

   
    public function tasksOnPage($id){
        return $this->cards()->where('page_id',$id);
    }

}

I tried redoing the whole site today, and make a livewire component for it. I may have broken the whole thing since now I am getting errors...

This is sorta how it looks now with the blade views when it doesn't show error. When I add the

@foreach ($kanban->columns as $column )

   @livewire('show_columns',['column'=>$column])

@endforeach


// Than in the livewire component 
@foreach ($column->cards as $card )
     @include('kanbans.show-card')
@endforeach


I am a fresh spawn with laravel and livewire >.<

I appreciate all the time everyone takes to help out, I need to retrace my steps and see where I broke it =/

Mar
29
1 month ago
Activity icon

Started a new Conversation Passing ID From Blade To Model Not Working?

Question I am trying to pass an $id from blade view @foreach loop to a Model so that I could return all the cards associated with this specific page.

  • Kanban has many Pages, Columns, Cards
  • Page and has many Cards
  • Column and has many Cards

The idea being, that you can click on all tasks and it would go to http://kanban.test/team/kanban/1/show-all and show all tasks.

When you click trough the pages those would be like tag filters and take you to http://kanban.test/team/kanban/1/1/show

enter image description here

When I manually set the page id = 1 it does work. When I try and pass the ID, it doesn't give any errors, but nothing shows up.

Manually Setting ID

// Column.php Model
public function tasksOnPage(){
        return $this->cards()->where('page_id',1);
    }

// Blade View
@foreach ($kanban->columns as $column )

   @foreach ($column->tasksOnPage as $card)
      @include('kanbans.show-card') 
   @endforeach

@endforeach

Trying to pass the id

When I do {{$page->id}} it does show the correct id of 1 inside each column.

// Column.php Model
public function tasksOnPage($id){
        return $this->cards()->where('page_id',$id);
    }

// Blade View
@foreach ($kanban->columns as $column )

   @foreach ($column->tasksOnPage($page->id) as $card)
       @include('kanbans.show-card') 
   @endforeach

@endforeach

If I was getting some errors, that would be helpful >.< . Any suggestions on how I could debug this to find what could possibly be the issue? Since the page loads fine, and there is no errors?

Mar
27
1 month ago
Activity icon

Replied to How To Make 2 Livewire Components Communicate?

Thanks @bezhansalleh for taking the time to help out! Much appreciated :)

Activity icon

Started a new Conversation How To Make 2 Livewire Components Communicate?

I have 2 separate livewire components that use the same Model. I am a bit lost with how the hydrate stuff works.

First component is create_kanban_form.php this is essentially just a button, that I can click and it would generate a new project.

<div>
    <form>
        <button wire:click="addKanban" class="h-8 w-8 rounded bg-blueGray-100  text-lg text-gray-900 focus:outline-none hover:text-white hover:bg-blue-500 ">
            <i class="bi bi-plus"></i>
        </button>
    </form>
</div>

This is the code for the livewire part

public function addKanban ()
    {
        $record = $this->validate([
            'team_id' => 'required',
            'icon' => 'required',
            'color' => 'required',
            'title' => 'required',
            'order' => 'required',
            'status' => 'required'
        ]);

        Kanban::create($record);

        $this->resetInputFields();
    }

When I click the button, it creates a new row in the database. However, the second component called show_kanban_sidebar_navigation.php is like on a delay. If I refresh the page, it shows the correct number of kanbans.

If I keep clicking the create button, it will be on a delay of one row.

<div>
    @foreach ($kanbans as $kanban )
        <div> {{$kanban->title}} </div>
    @endforeach
</div>
public function render()
    {
        $kanbans = Kanban::all();

        return view('kanbans.show-kanban-sidebar-navigation', [
            'kanbans' => Kanban::where('status', $this->active)
            ->orderBy('order', 'ASC')->get(),
        ]);
    }

Is there a way for me to pass a request, so that as soon as the database gets a new record. The separate livewire component would update as well without needing a refresh?

I understand that when I have everything in a single livewire component then when I add records, they update in real-time. Trying to figure out how to do this, if possible with splitting up the components.

I think this has to do with nesting? https://laravel-livewire.com/docs/2.x/nesting-components

Any help much appreciated, even a link to the correct documentation :)

Mar
26
1 month ago
Activity icon

Replied to Laravel SubDays Returning 0 Results

Aah thank you for clarification! :)

Activity icon

Started a new Conversation Laravel SubDays Returning 0 Results

Is there a package update or something that I am missing which might cause subDays to not work?

When I use Carbon for this month, and today. It works perfectly

    public function thisMonth(){
        return $this->adjustments()
            ->whereYear('date',now()->year)
            ->whereMonth('date',now()->month)
            ->sum('value');
    }

    public function today(){
        return $this->adjustments()
            ->whereDate('date',today())
            ->sum('value');
    }

But when I do try and write something with subDays, it is not showing an error or anything. It is finding no results

public function last30(){
        return $this->adjustments()
            ->whereDate('date',now()->subDays(30))
            ->sum('value');
    }

What am I not seeing here?

Any help much appreciated :)

Mar
24
1 month ago
Activity icon

Replied to Livewire Click Away?

Here are the two approaches side by side

// Method 1
<input x-show="edit === true" name="account"  type="text" placeholder="{{$sportsbook -> account}}" wire:model="account" wire:change="updateAccount({{ $sportsbook->id }})" >    

// Method 2
<input x-show="edit === true" name="account"  type="text" placeholder="{{ $sportsbook-> account }}" wire:model.lazy="updateAccount({{ $sportsbook->id }})"  > 

The error is this when I change something in method 2

C:\Users\home\Desktop\code\sportsapp\
Livewire\Exceptions\PropertyNotFoundException
Property [$updateAccount(1)] not found on component: [sportsbooks]
http://sportsapp.test/?sortAsc=true
Mar
23
1 month ago
Activity icon

Replied to Livewire Click Away?

I got an error trying to do this method, not sure if I am implementing it correctly

<input name="account"  type="text" placeholder="{{$example -> account}}" wire:model.lazy="update({{ $account->id }})"  >

The other solution worked tho, however, would love to learn this approach as well :) I will try some more stuff out

Activity icon

Replied to Livewire Click Away?

Thank you!! This works perfectly :)

Mar
21
1 month ago
Activity icon

Started a new Conversation Livewire Click Away?

I haven't been able to find anything relating to an action to submit an update request when we click away. Something like wire:clickaway = "update( {{ example -> id }} )"

Essentially, I am trying to create the effect of when a user clicks on the title, it will open an input box. Than when user clicks away, it will save the data that has been updated in the box.

Right now, I got this working with a checkmark icon appearing when the edit is true using Alpine

<div x-data="{edit : false}"  >

 <h2 @click="edit = true" x-show="edit === false" >{{$example -> title}} </h2>

 <div x-show="edit === true">
  <input name="title"  type="text" placeholder="{{$example -> title}}" wire:model="title"  >
  <i class="bi bi-check "  wire:click="update({{ $example->id }})" @click="edit = false"></i>
 </div>

</div>

I wanted to change this to something like

<div x-data="{edit : false}"  >

 <h2 @click="edit = true" x-show="edit === false" >{{$example -> title}} </h2>

 <input x-show="edit === true" name="title"  type="text" placeholder="{{$example -> title}}" wire:model="title" wire:clickaway="update({{ $example->id }})" @click.away="edit = false" >


</div>

Is there a way to pass data into livewire update using the alpine @click.away?

Activity icon

Awarded Best Reply on Livewire: Public Function Update Issue

I was able to get the update working with

public function update($column)
    {
        $this->validate([
            'title' => 'required',
            'kanban_id' => 'required',
        
        ]);

        
        $column = Column::find($column);
        if ($column) {
            $column->update([
                'title' => $this->title,
            ]);
        }

        $this->resetInputFields();
       

    }

Hope this helps anyone else that might be trying to do create and update on the same page :)

Activity icon

Replied to Livewire: Public Function Update Issue

I was able to get the update working with

public function update($column)
    {
        $this->validate([
            'title' => 'required',
            'kanban_id' => 'required',
        
        ]);

        
        $column = Column::find($column);
        if ($column) {
            $column->update([
                'title' => $this->title,
            ]);
        }

        $this->resetInputFields();
       

    }

Hope this helps anyone else that might be trying to do create and update on the same page :)

Activity icon

Replied to Livewire: Public Function Update Issue

I tried this as well, I watched the Eloquent series, but still don't get this.

public function update()
    {
        $request = $this->validate([
            'title' => 'required',
        ]);

        if ($this->id) {
            $column = Column::find($this->id);
            $column->update([
                'title' => $this->title,
            ]);
        }
    }

To create columns, all I had to do was

public function store ()
    {
        $request = $this->validate([
            'kanban_id' => 'required',
            'title' => 'required',
   
        ]);

        Column::create($request);
Mar
20
1 month ago
Activity icon

Started a new Conversation Livewire: Public Function Update Issue

Hmm...

What did I mess up here if anyone can help.

Livewire

public function update()
    {
        $request = $this->validate([
            'title' => 'required',
        ]);

        if ($this->request) {
            $request = Column::find($this->id);
            $request->update([
                'title' => $this->title,
            ]);
        }
     
        session()->flash('success','Kanban Column updated successfully.');

    }

I also tried this, but don't seem to get any luck to get this work.

public function update(Column $column)
    {
        $request = $this->validate([
            'title' => 'required',
        ]);

        $column->update($request->all());
     
        session()->flash('success','Kanban Column updated successfully.');

    }

Livewire Blade View

<form>
    <input type="text" name="title" placeholder=" {{$column->title}} ">
                      
    <i  class="bi bi-check text-4xl text-green-600 hover:text-green-800" wire:click.prevent="update({{ $column->id }})" ></i>
                        
    <i class="bi bi-trash-fill text-2xl text-red-600 hover:text-red-800 "  wire:click.prevent="delete({{ $column->id }})"></i>
</form>

Getting a bit confused with some of the livewire crud guides since I set up my blade view to create and update as one file instead of two by doing the @foreach thing with the $updateField = true;. I wanted to keep the files to a minimum so I used Alpine JS to switch to edit mode instead.

@foreach ($columns as $column )
            <div x-data="{edit : false}" class="flex" x-cloak>
                <div x-show="edit == false" class="flex p-4 space-x-4">
                    <div @click="edit = true" class="text-base font-semibold">
                         {{$column->title}} 
                    </div>
                </div>

                <div x-show="edit == true">
                    <div @click.away="edit = false"  x-show="edit == true" class="flex p-4 space-x-4 h-16 items-center">
                        <form>
                            <input type="text" name="title" placeholder=" {{$column->title}} ">
                      
                            <i  class="bi bi-check text-4xl text-green-600 hover:text-green-800" wire:click.prevent="update({{ $column->id }})" ></i>
                        
                            <i class="bi bi-trash-fill text-2xl text-red-600 hover:text-red-800 "  wire:click.prevent="delete({{ $column->id }})"></i>
                        </form>
                             
                    </div>
                </div>
            </div>
        
@endforeach

Thanks in advance for any help :)

Mar
19
1 month ago
Activity icon

Replied to How To Render Child Data Based On Parent Data?

This is exactly what I needed! Thank you so much for the help :)

Activity icon

Commented on Introduction And Demo

Wow! This looks amazing! :) Thanks for awesome tutorial

Activity icon

Started a new Conversation How To Render Child Data Based On Parent Data?

First, I am not sure what this type of thing is called. Any help with clarification for the proper terminology is much appreciated, so I can actually have a better chance of looking this stuff up haha.

What I am trying to do is some CRUD functionality with livewire for columns in the settings page for the kanban, based on what Kanban id it is. Essentially want to be able to add tags, columns, reorder stuff ect in this view. I was able to get this to work with regular Laravel CRUD redirecting back after each form submission lol, figured this should be done with livewire but getting completely lost with this stuff.

I created this route Route::get('/kanban/{kanban}/edit', [KanbanController::class, 'edit'])->name('kanban.edit'); and on that blade views/kanban/edit

I am able to successfully render the data using

<h2>Title:{{$kanban->title}} </h2>
 @foreach ($kanban->columns as $column )
  		<h3>column: {{$column->title}} </h3>
 @endforeach

This is how my edit.blade.php looks

@section('content')
       
        <h2>Title:{{$kanban->title}} </h2>
        @foreach ($kanban->columns as $column )
            <h3>column: {{$column->title}} </h3>
        @endforeach

        <div>
            @livewire('kanban-columns-edit')
        </div>
    @endsection

This is the views/livewire/kanban-columns-edit.blade.php

<div class="pt-10">
    Live wire component - how to display the column names here?
    
    @foreach ($columns as $column)
       
        <p>{{$column -> title }}</p>
         
    @endforeach
</div>

This is how I setup the KanbanColumnsEdit.php

<?php

namespace App\Http\Livewire;
use App\Models\Column;
use Livewire\Component;

class KanbanColumnsEdit extends Component
{
    public $kanban_id;
    public $color;
    public $title;
    public $order;

    public function resetInputFields()
    {
        $this->title = '';
    }

    public function store ()
    {
        $request = $this->validate([
            'kanban_id' => 'required',
            'color' => 'required',
            'title' => 'required',
            'order' => 'required',
        ]);

        Column::create($request);

        session()->flash('success','Kanban Column created successfully.');

        $this->resetInputFields();
    }

    public function render()
    {
        $columns = Column::orderBy('id','DESC')->get();

        return view('livewire.kanban-columns-edit');
    }
    
}

So the URL where this is getting rendered is like http://oneproject.test/kanban/1/show

I can't even get it to show all the columns without the filtering >.<

Also as a side note... This is the most beautiful code markup editor I have ever seen! :O