IvanRadojevic

Member Since 1 Year Ago

Experience Points
45,940
Total
Experience

4,060 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
314
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.

  • Community Pillar

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

Level 10
45,940 XP
Jan
17
1 day ago
Activity icon

Replied to Property 'pivot' Of Non-object

Oh, yes. What a mistake-a to make-a ;)

Activity icon

Replied to Property 'pivot' Of Non-object

New error: Call to undefined method App\Models\Station::updateExistingPivot()

Activity icon

Started a new Conversation Property 'pivot' Of Non-object

Error is: Trying to get property 'pivot' of non-object

$stationOrder = 5;
foreach ($this->line->stations() as $s) {
            if ($s->pivot->order > $stationOrder) {
                $s->updateExistingPivot($s->id, ['order' => $s->pivot->order - 1]);
            }
        }

//model Line
public function stations()
    {
        return $this->belongsToMany(Station::class)->withPivot('order');
    }
Jan
16
2 days ago
Activity icon

Started a new Conversation WhereDoesntHave

I need Categories which not belongsTo $post->id = 1

$post = Post::find(1);
    
return Category::whereDoesntHave('posts', function($query) {
        $query->where('id', $post->id);
})->get();

//Model Category
public function posts()
    {
        return $this->belongsToMany(Post::class);
    }
Jan
15
3 days ago
Activity icon

Commented on Inertia Integration

Yes, and I am waiting for that course for a mini project. Unfortunately I don’t have enough time to research the documentation to get started. I would like to be introduced to the story by a video tutorial.

Activity icon

Replied to Using Both Vue Js And Jquery With Laravel Mix

Absolutely, but jquery is slowly losing significance in modern web dev,

Activity icon

Started a new Conversation Let Apline.js Mutliselect Work For Us

Why we use some multiselect jquery packages, when we can instead apply Alpine and Livewire. The values on the frontend are there, but how to conect to Livewire class?

<select wire:model="selected" x-cloak id="select" multiple>
  @foreach ($items as $item)  
  <option value="{{ $item->id }}">{{ $item->name }}</option>
  @endforeach
</select>

<div x-data="dropdown()" x-init="loadOptions()" class="w-full md:w-1/2 flex flex-col items-center h-64 mx-auto">
  <input name="values" type="hidden" x-bind:value="selectedValues()">
  <div class="inline-block relative w-64">
    <div class="flex flex-col items-center relative">
      <div x-on:click="open" class="w-full">
        <div class="my-2 p-1 flex border border-gray-200 bg-white rounded">
          <div class="flex flex-auto flex-wrap">
            <template x-for="(option,index) in selected" :key="options[option].value">
              <div class="flex justify-center items-center m-1 font-medium py-1 px-1 bg-white rounded bg-gray-100 border">
                <div class="text-xs font-normal leading-none max-w-full flex-initial x-model=" options[option] x-text="options[option].text"></div>
                <div class="flex flex-auto flex-row-reverse">
                  <div x-on:click.stop="remove(index,option)">
                    <svg class="fill-current h-4 w-4 " role="button" viewBox="0 0 20 20">
                      <path d="M14.348,14.849c-0.469,0.469-1.229,0.469-1.697,0L10,11.819l-2.651,3.029c-0.469,0.469-1.229,0.469-1.697,0
                                           c-0.469-0.469-0.469-1.229,0-1.697l2.758-3.15L5.651,6.849c-0.469-0.469-0.469-1.228,0-1.697s1.228-0.469,1.697,0L10,8.183
                                           l2.651-3.031c0.469-0.469,1.228-0.469,1.697,0s0.469,1.229,0,1.697l-2.758,3.152l2.758,3.15
                                           C14.817,13.62,14.817,14.38,14.348,14.849z" />
                    </svg>

                  </div>
                </div>
              </div>
            </template>
            <div x-show="selected.length == 0" class="flex-1">
              <input placeholder="Select a option" class="bg-transparent p-1 px-2 appearance-none outline-none h-full w-full text-gray-800" x-bind:value="selectedValues()">
            </div>
          </div>
          <div class="text-gray-300 w-8 py-1 pl-2 pr-1 border-l flex items-center border-gray-200 svelte-1l8159u">

            <button type="button" x-show="isOpen() === true" x-on:click="open" class="cursor-pointer w-6 h-6 text-gray-600 outline-none focus:outline-none">
              <svg version="1.1" class="fill-current h-4 w-4" viewBox="0 0 20 20">
                <path d="M17.418,6.109c0.272-0.268,0.709-0.268,0.979,0s0.271,0.701,0,0.969l-7.908,7.83
    c-0.27,0.268-0.707,0.268-0.979,0l-7.908-7.83c-0.27-0.268-0.27-0.701,0-0.969c0.271-0.268,0.709-0.268,0.979,0L10,13.25
    L17.418,6.109z" />
              </svg>

            </button>
            <button type="button" x-show="isOpen() === false" @click="close" class="cursor-pointer w-6 h-6 text-gray-600 outline-none focus:outline-none">
              <svg class="fill-current h-4 w-4" viewBox="0 0 20 20">
                <path d="M2.582,13.891c-0.272,0.268-0.709,0.268-0.979,0s-0.271-0.701,0-0.969l7.908-7.83
    c0.27-0.268,0.707-0.268,0.979,0l7.908,7.83c0.27,0.268,0.27,0.701,0,0.969c-0.271,0.268-0.709,0.268-0.978,0L10,6.75L2.582,13.891z
    " />
              </svg>

            </button>
          </div>
        </div>
      </div>
      <div class="w-full px-4">
        <div x-show.transition.origin.top="isOpen()" class="absolute shadow top-100 bg-white z-40 w-full left-0 rounded max-h-select" x-on:click.away="close">
          <div class="flex flex-col w-full overflow-y-auto h-64">
            <template x-for="(option,index) in options" :key="option" class="overflow-auto">
              <div class="cursor-pointer w-full border-gray-100 rounded-t border-b hover:bg-gray-100" @click="select(index,$event)">
                <div class="flex w-full items-center p-2 pl-2 border-transparent border-l-2 relative">
                  <div class="w-full items-center flex justify-between">
                    <div class="mx-2 leading-6" x-model="option" x-text="option.text"></div>
                    <div x-show="option.selected">
                      <svg class="svg-icon" viewBox="0 0 20 20">
                        <path fill="none" d="M7.197,16.963H7.195c-0.204,0-0.399-0.083-0.544-0.227l-6.039-6.082c-0.3-0.302-0.297-0.788,0.003-1.087
                            C0.919,9.266,1.404,9.269,1.702,9.57l5.495,5.536L18.221,4.083c0.301-0.301,0.787-0.301,1.087,0c0.301,0.3,0.301,0.787,0,1.087
                            L7.741,16.738C7.596,16.882,7.401,16.963,7.197,16.963z"></path>
                      </svg>
                    </div>
                  </div>
                </div>
              </div>
            </template>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
function dropdown() {
                return {
                    options: [],
                    selected: [],
                    show: false,
                    open() { this.show = true },
                    close() { this.show = false },
                    isOpen() { return this.show === true },
                    select(index, event) {

                        if (!this.options[index].selected) {

                            this.options[index].selected = true;
                            this.options[index].element = event.target;
                            this.selected.push(index);

                        } else {
                            this.selected.splice(this.selected.lastIndexOf(index), 1);
                            this.options[index].selected = false
                        }
                    },
                    remove(index, option) {
                        this.options[option].selected = false;
                        this.selected.splice(index, 1);


                    },
                    loadOptions() {
                        const options = document.getElementById('select').options;
                        for (let i = 0; i < options.length; i++) {
                            this.options.push({
                                value: options[i].value,
                                text: options[i].innerText,
                                selected: options[i].getAttribute('selected') != null ? options[i].getAttribute('selected') : false
                            });
                        }


                    },
                    selectedValues(){
                        return this.selected.map((option)=>{
                            return this.options[option].value;
                        })
                    }
                }
            }
</script>

//lw class
//public $selected = [];

//All credit goes to:
//Andre Prilly Kurniawan

Jan
14
4 days ago
Activity icon

Replied to Update Pivot ?

Yup, very clear. Brilliant, as always!

Activity icon

Started a new Conversation Update Pivot ?

Call to undefined method App\Models\Station::updateExistingPivot()

How to update pivot

foreach($list as $station) {
            $this->line->stations()->find($station['value'])
                ->updateExistingPivot($station['value'], ['order' => $station['order']]);
}

//model relation:
public function stations()
    {
        return $this->belongsToMany(Station::class)->withPivot('order', 'price');
    }
Activity icon

Replied to Organising VueJS (2) Code In A Laravel (7) App

resources/js/app.js This is default Laravel file where you organise Vue, packages, etc... If you are making an SSR app that is good place to do it, if you want to make SPA app, it is better to use Vue cli or Nuxt.js for frontend.

Jan
13
5 days ago
Activity icon

Replied to Livewire Sortable

Oh yeah, this is something new, just when I need it!

Activity icon

Started a new Conversation Livewire Sortable

Has anyone tried to use this package. Only the frontend example is presented in the docs. There is no example of what a Livewire class should look like.

https://github.com/livewire/sortable

Activity icon

Replied to Livewire Validation

Tell me some nice way to make sortable list with draggable elements usling Livewire. It seems to me, to be much easier to do with Vue.

Jan
12
6 days ago
Activity icon

Replied to Livewire Validation

I can. Liveware becomes hell if you try to do something more than classic forms. You need to combine with Alpine.js, and only the creator knows that :) Bye!

Activity icon

Started a new Conversation WithCount() & OrderBy

How to do withCount('stations') ? I have an error when I attempt this:

Route::get('/', function () {
    $line = Line::find(1);

    return $line->withCount('stations')->stations()->orderBy('pivot_order')->get();
});

//Line model relationship:
public function stations()
    {
        return $this->belongsToMany(Station::class)->withPivot('order'); 
   }
Activity icon

Started a new Conversation WithCount() & Pivot OrderBy

How to do withCount('stations'), when is include orderBy pivot_order?

Route::get('/', function () {
    $line = Line::find(1);

    return $line->stations()->orderBy('pivot_order')->get();
});

//Line model relationship:
public function stations()
    {
        return $this->belongsToMany(Station::class)->withPivot('order'); 
   }
Jan
11
1 week ago
Activity icon

Replied to WithCount() In Many To Many

I didn't put a complete query here thinking the problem is in relation... Problem is ->orderBy('pivot_order') which does not work with withCount();

  return $line->with('stations')->withCount('stations')->orderBy('pivot_order')->get();
Activity icon

Started a new Conversation WithCount() In Many To Many

How to get withCount('stations') ?

Route::get('/', function () {
    $line = Line::find(1);

    return $line->stations()->get();
});

//Line model relationship:
public function stations()
    {
        return $this->belongsToMany(Station::class);
    }
Jan
10
1 week ago
Activity icon

Started a new Conversation Livewire Validation

Hot to validate data from this wire:model?

wire:model.debounce.500ms="editing.name"

//try this, but doesn`t work
$this->validate([
            'editing.name' => ['required'], 
        ]);

$product->name = $this->editing['name'];
Jan
06
1 week ago
Activity icon

Replied to Livewire Dynamically Code

It's not clear to me what you want, but you probably need to use foreach loop in template, and than pass id to update function.

Jan
05
1 week ago
Activity icon

Replied to Class "Database\Seeders\Bakset" Not Found

Oh :) Bakset -> Basket :)

Activity icon

Replied to Class "Database\Seeders\Bakset" Not Found

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Basket extends Model
{
    use HasFactory;

    protected $guarded = [
    ];

    public function timetable()
    {
        return $this->belongsTo(Timetable::class);
    }
}
Activity icon

Replied to Class "Database\Seeders\Bakset" Not Found

Try in tinker:

PHP Error: Class "App\Models\Bakset" not found in Psy Shell code on line 1

Activity icon

Replied to Class "Database\Seeders\Bakset" Not Found

It is not data type :|

Activity icon

Replied to Class "Database\Seeders\Bakset" Not Found

It is probably data type, I have mistake integer instead string...

Activity icon

Started a new Conversation Class "Database\Seeders\Bakset" Not Found

I try to create record in DatabaseSeeder as I usually do, but have an error. I import model Basket. Model basket has relationship:

 public function timetable()
    {
        return $this->belongsTo(Timetable::class);
    }


//DatabaseSeeeder Class
Bakset::create([
            'timetable_id' => 2,
            'ticket_price' => 90,,
            'quantity' => 3,
            'total_price' => 270,
            'start_station' => 'Paris',
            'end_station' => 'London',
        ]);
Activity icon

Replied to Get() Order

Wow, I didn't know that. I thought that is default order for get(), all()... by Id. Yes, I chechked:

 Line::orderBy('id'); result is 1, 2, 3...
Jan
04
2 weeks ago
Activity icon

Started a new Conversation Get() Order

When I try to:

return  Line::get();

My first record is with id = 2, not 1. This is the first time this has happened to me. I turned it off timestaps. Could that be the reason? In my db table everything is normal, first record is id 1

[
{
"id": 2,
},
{
"id": 1,
},
{
"id": 3,
}
]
Activity icon

Awarded Best Reply on Many To Many Attach With Pivot Input

It is enough "order", not "pivot_order"

Activity icon

Replied to Many To Many Attach With Pivot Input

It is enough "order", not "pivot_order"

Activity icon

Started a new Conversation Many To Many Attach With Pivot Input

How to attach many to many records with pivot column? I try this in seeder, and have an error:

$line1 = Line::find(1);
$line1->stations()->attach([
        	1 => ['pivot_order' => 1],
        	2 => ['pivot_order' => 4],
        	3 => ['pivot_order' => 2],
        	4 => ['pivot_order' => 5],
        	5 => ['pivot_order' => 3],
        	6 => ['pivot_order' => 6],
]);

// Line Model:
public function stations()
    {
        return $this->belongsToMany(Station::class)->withPivot('order');
    }
Activity icon

Replied to Homestead - Npm Install Error

I do not understand very well. Homestead should have node.js already installed.

Activity icon

Started a new Conversation Homestead - Npm Install Error

I cant install npm into the project.

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/vagrant/Projects_Laravel/Project1/node_modules/babel-code-frame/node_modules/ansi-styles/package.json.2634078580
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/vagrant/Projects_Laravel/Project1/node_modules/babel-code-frame/node_modules/ansi-styles/package.json.2634078580'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2021-01-03T21_50_37_309Z-debug.log
Jan
03
2 weeks ago
Activity icon

Started a new Conversation Homestead - Npm Install Error

I have npm errors during instalation in homestead...

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/vagrant/Projects_Laravel/Project1/node_modules/babel-code-frame/node_modules/ansi-styles/package.json.2634078580
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/vagrant/Projects_Laravel/Project1/node_modules/babel-code-frame/node_modules/ansi-styles/package.json.2634078580'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2021-01-03T21_50_37_309Z-debug.log

I saw that one of the soulution is to put nfs in yaml file: type: "nfs" I do that, but wihout success.

...

I try to vagrant reload --provision, and have this info:

It appears your machine doesn't support NFS, or there is not an adapter to enable NFS on this machine for Vagrant. Please verify that nfsd is installed on your machine, and try again. If you're on Windows, NFS isn't supported. If the problem persists, please contact Vagrant support. What to do?

Jan
02
2 weeks ago
Activity icon

Replied to VUE.js Axios Post Error 500.

axios.post("{{ route('api.comments.store') }} ..."

What is this, is this some package? If is not, you should insert url, not route-name...

axios.post(`/api/comments`, { ...
Activity icon

Replied to Lumen Vs Sanctum Vs Passport

Lumen is a micro framework, quite a different thing than Sanctum and Passport.

Activity icon

Started a new Conversation Tailwind Overflow

Tailwind overflow is only thing that drives me crazy all the time...

I set the element to be scrollable by x-axis, but not, text is hidden...

 <div class="overflow-y-hidden overflow-x-auto p-4 w-2/3 h-64 bg-orange-400 ">
                    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
Dec
31
2 weeks ago
Activity icon

Replied to Blog Categories Page

You need to use query string:

 foo.test/articles/?category=first_category
 foo.test/articles/?category=second_category
...
Activity icon

Replied to Form Submission Doesn't Work Unless User Is Logged In

nope, that middleware means that route needs to be authorise...

Activity icon

Replied to Form Submission Doesn't Work Unless User Is Logged In

$review->user_id = auth()->user()->id; That means User must be log in

Activity icon

Replied to Tailwind Color Extension Doesn't Show Up

In my latest project I dont use transparent and curent, only which I use...

gray: colors.blueGray, orange: colors.orange, white: colors.white,

Activity icon

Replied to Form Submission Doesn't Work Unless User Is Logged In

for the example, from controller

Activity icon

Replied to Tinymce With Livewire

<div x-data="{ trix: @entangle('content').defer }">
    <input id="content" name="content" type="hidden" value="{{$content}}" />
     <div wire:ignore>
         <trix-editor x-model="trix" input="content">
         </trix-editor>
     </div>
</div>

in head:
<link rel="stylesheet" type="text/css" href="https://unpkg.com/[email protected]/dist/trix.css">
in body
<script src="https://unpkg.com/[email protected]/dist/trix.js"></script>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
Activity icon

Replied to Tailwind Color Extension Doesn't Show Up

I think Tailwind should be v2

Activity icon

Replied to Tailwind Color Extension Doesn't Show Up

restart browser, try in another browser?