IvanRadojevic

IvanRadojevic

Member Since 8 Months Ago

Experience Points
22,130
Total
Experience

2,870 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
159
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.

Level 5
22,130 XP
Aug
14
1 day ago
Activity icon

Replied to Get Real With Laravel Echo / Broadcasting

Not, I want message in log file to see that broadcasting is working...

Activity icon

Started a new Conversation Get Real With Laravel Echo / Broadcasting

I followed the code from the Laracast series Get real with Laravel Echo, and try to check log file is broadcasting working. This is all I did. Do I need to do anything else, since I don't have any message in the log file.


<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class OrderStatusUpdated implements ShouldBroadcast                      
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        //return new PrivateChannel('channel-name');

        return new Channel('orders');
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

use App\Events\OrderStatusUpdated;


Route::get('/test', function () {
event(new OrderStatusUpdated());
return view('welcome');
});

/////////////////////////////////////////////////////////////////////////////////////////////////////////

BROADCAST_DRIVER=log

/////////////////////////////////////////////////////////////////////////////////////////////////////////

/*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

Aug
13
2 days ago
Activity icon

Started a new Conversation Possible Reason Why Broadcasting Doesn't Work.

Does anyone know what is the possible reason that broadcating doesn´t work. Should it work in all development environments? I try to check in log file according to the Laracast series "Get real with Laravel Echo", i have no feedback on whether it works.

Comments from episode 1 :

btanner
•
3 months ago
When I dispatch my event, the broadcastOn() method never fires. I have Log::info(xx); in my constructor for the event, and that logs, but the log in my broadcastOn() method is never run. Any ideas of what I could be doing wrong?

christopherwilbraham
•
6 days ago
I'm still having this same issue. BroadcastController never registers in routes


onathanDolbec
•
5 months ago
(edited)
When I enter 'http://echo-series.test', I just get a 'server not responding' message. Any ideas?

I have the same problem.

Activity icon

Replied to Checking Broadcast?

Do I need to register an event here, in EventServiceProvider?

<?php

namespace App\Providers;

use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        "App\Events\NewCustomerHasRegisteredEvent" => [
            "App\Listeners\WelcomeNewCustomerListener",
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();

        //
    }
}
Activity icon

Replied to Checking Broadcast?

Yes I imported event, when I try var_dump (OrderStatusUpdated::dispatch());

I have :

array(0) { }
Aug
12
3 days ago
Activity icon

Started a new Conversation Checking Broadcast?

How to check is broadcasting working? I follow the Laracast code from the series "Get real with Laravel Echo", but nothing happens, when I try this: There is no message in log file

BROADCAST_DRIVER=log


Route::get('/', function () {
	event(new OrderStatusUpdated());
});



<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class OrderStatusUpdated implements ShouldBroadcast                      
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        //return new PrivateChannel('channel-name');

        return new Channel('orders');
    }
}
Activity icon

Replied to Get Real With Laravel Echo

Yes, yes... hmm strange, and I'm not the only one with that problem.

Activity icon

Replied to Get Real With Laravel Echo

public function broadcastOn()
    {
        //return new PrivateChannel('channel-name');

        return new Channel("orders");
    }
Activity icon

Started a new Conversation Get Real With Laravel Echo

I try to broadcast channel from the Laracast series. Should be shown message in the Log file, but nothing happens. I see the others complaining too.

Route::get('/', function () {
	event(new OrderStatusUpdated());
});
Aug
09
6 days ago
Activity icon

Started a new Conversation Delete Polymorphic Relationship

I have model Reply with polymorphic relationship with model Favorite. I want to delete reply, and in the same time that relation in favorites table. What is the best way to this, beacause, cascade deleting is not possible?

class Reply extends Model
{

    public function favorites()
    {
        return $this->morphMany('App\Favorite', 'favorited');
    }

}
Activity icon

Commented on How To Construct An Activity Feed With TDD: Part 2

created_at is automatically set as Carbon instance. "format" is Carbon method.

Activity icon

Awarded Best Reply on Property [type] Does Not Exist On This Collection Instance.

I left an old loop in the blade.php file. Everything is ok now.

Activity icon

Replied to Property [type] Does Not Exist On This Collection Instance.

I left an old loop in the blade.php file. Everything is ok now.

Activity icon

Started a new Conversation Property [type] Does Not Exist On This Collection Instance.

This code in controller is working:

return $activities = $user->activity()->latest()->with("subject")->get();

but this is not (Property [type] does not exist on this collection instance.) Why?

$activities = $user->activity()->latest()->with("subject")->get()->groupBy(function ($activity) {
		return $activity->created_at->format("Y-m-d");
	});	
Aug
05
1 week ago
Activity icon

Started a new Conversation SortByDesc

error: Too few arguments to function Illuminate\Support\Collection::get(), 0 passed in

Why doesn't this work?

$t = Thread::all();

if (request("popularity")) {    

            $threads = $t->sortByDesc('replies_count');
        }

$threads = $threads->get();
Aug
03
1 week ago
Activity icon

Replied to Laracasts Videos Not Playing! (Laravel From Scratch)

I have the same problems. Laracast videos for me only working in Chrome.

Activity icon

Awarded Best Reply on Laracats Forum TDD / Missing Required Parameters For [Route: Threads.show]

Okay, I need to put it in a array.

<a href="{{route('threads.show', [$thread->channel->slug, $thread->id])}}">{{$thread->title}} <a>
Activity icon

Replied to Laracats Forum TDD / Missing Required Parameters For [Route: Threads.show]

Okay, I need to put it in a array.

<a href="{{route('threads.show', [$thread->channel->slug, $thread->id])}}">{{$thread->title}} <a>
Activity icon

Started a new Conversation Laracats Forum TDD / Missing Required Parameters For [Route: Threads.show]

I try to make route like a Jeffrey, but have error: Missing required parameters for [Route: threads.show] [URI: threads/{channel}/{thread}].

//link
<a href="{{route('threads.show', $thread->channel->slug, $thread->id)}}">{{$thread->title}} <a>

//controller
public function show($channelId, Thread $thread)
    {
        return view("threads.show", compact("thread"));
    }

//routes
Route::get('threads/{channel}/{thread}', '[email protected]')->name('threads.show');
Aug
01
2 weeks ago
Activity icon

Started a new Conversation Error Unit Test: Unable To Locate Factory

I use this factory in feauture test and it is working. What is the problem in unit testing?

  1. Tests\Unit\ReplyTest::it_has_body InvalidArgumentException: Unable to locate factory for [App\Reply].

namespace Tests\Unit;

use PHPUnit\Framework\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;


class ReplyTest extends TestCase
{

	use RefreshDatabase;

    /** @test */
    public function it_has_body()
    {
        $reply = factory('App\Reply')->create();

        $this->assertInstanceOf('App\User', $reply->owner);
    }
}
Jul
30
2 weeks ago
Activity icon

Replied to Laravel Shared Hosting Failed

Never again shared hosting! That's a better description. :)

Activity icon

Started a new Conversation Laravel Shared Hosting Failed

I try to deploy laravel on shared hosting. Veu.js axios posting doesnt working, but what's weirder that if, elseif blade statemans doesn't work also?!?

Does anyone have experience with these problems.

Jul
29
2 weeks ago
Activity icon

Replied to Chart.js Labels

$(function () {

    var areaChartCanvas = $('#areaChart').get(0).getContext('2d')

    var areaChartData = {
      labels  : [
      @foreach ($result as $key => $value)
                  "{{ $key }}",				//30 dates
      @endforeach
                ],
      datasets: [
        {
          label               : 'Value',
          backgroundColor     : 'rgba(60,141,188,0.9)',
          borderColor         : 'rgba(60,141,188,0.8)',
          pointRadius          : false,
          pointColor          : '#3b8bba',
          pointStrokeColor    : 'rgba(60,141,188,1)',
          pointHighlightFill  : '#fff',
          pointHighlightStroke: 'rgba(60,141,188,1)',
          data                : [
       @foreach ($result as $key => $value)
                  "{{ $value }}",	//30 values
       @endforeach
          ]
        },       
      ]
    }

    var areaChartOptions = {
      maintainAspectRatio : false,
      responsive : true,
      legend: {
        display: false
      },
      scales: {
        xAxes: [{
         

 gridLines : {
            display : false,
          },
          

     

        }],
        yAxes: [{
          gridLines : {
            display : false,
          }
        }]
      }
    }

    
    var areaChart       = new Chart(areaChartCanvas, { 
      type: 'line',
      data: areaChartData, 
      options: areaChartOptions
    })




 });
Activity icon

Replied to Chart.js Labels

Thank you, but it does not work. I have a blank page, the graphic is completely lost.

Activity icon

Started a new Conversation Chart.js Labels

Does anyone knowing how to show every 7th date on labels, instead 30 dates?

Jul
28
2 weeks ago
Activity icon

Replied to Instead 5s, Duration Of Toast 1s? Laravel, Vue.js, Axios

You want to say that I can send regular http request from Vue component? I didn't even know this was possible.

Activity icon

Started a new Conversation Currency Format

Value of number:format method is 16,012.00 . (,/.)

How to get 16.012,00 ? (./,)

{{ number_format($reservation->total, 2) }}
Activity icon

Replied to Instead 5s, Duration Of Toast 1s? Laravel, Vue.js, Axios

But how to make redirect in controller after ajax post?

Activity icon

Replied to DataTable Checkbox Not In Controller Request

value="{{ $member->user_id }}"
Activity icon

Replied to Instead 5s, Duration Of Toast 1s? Laravel, Vue.js, Axios

Form use datepicker, multi select options etc. etc.

Anyway, thank you very much!

Activity icon

Replied to Instead 5s, Duration Of Toast 1s? Laravel, Vue.js, Axios

I am posting form with ajax and use post route /reservations, then I want to redirect to get/head route /reservations.

Activity icon

Replied to Get Order_id From Hidden Input

Use grave accent * 3 time above code, so we'll see what it's about.

Activity icon

Started a new Conversation Instead 5s, Duration Of Toast 1s? Laravel, Vue.js, Axios

Redirection makes me problem, immediately redirect to new route. How to enablel real duration of toast (5000ms). ?

this.form.post('/reservations')
              .then(() => {
                      this.$toasted.show("Reservation is ok!", { 
                      theme: "bubble", 
                      position: "top-right", 
                      duration : 5000
                      }); 
              window.location.href = '/reservations'    
              })
              .catch(() => {
                 
              });
        },
Jul
26
2 weeks ago
Activity icon

Started a new Conversation Undefined Variable, Notification

I have error Undefined variable: reservation ?

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class InformUser extends Notification
{
    use Queueable;

    protected $reservation;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->reservation = $reservation;              <<< error?!?        
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['database'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line('The introduction to the notification.')
                    ->action('Notification Action', url('/'))
                    ->line('Thank you for using our application!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            'reservation' => $this->reservation,
        ];
    }
}

public function __invoke(Request $request, $id)
    {
        $user = auth()->user();
        
        $reservation = Reservation::findOrFail($id);
        $reservation->notification = $request->notification;
        $reservation->save();

        Notification::send($user, new InformUser($reservation));

        return back()->with('success', 'Notification sent');
    }
Jul
25
3 weeks ago
Activity icon

Replied to How To Chain Multi Values In Query String?

Tnak you, this is what I want.

Activity icon

Replied to How To Chain Multi Values In Query String?

Laravel have open-source philosophy. I’m not asking to get the job done, but what the syntax is in the blade. If it's all about payment, then this forum should not exist.

Activity icon

Replied to How To Chain Multi Values In Query String?

Nice answer, but this is not a literature forum, so it would be nice to give answers in codes :)

Activity icon

Replied to How To Chain Multi Values In Query String?

Yes, I know that with diferent keys; but I want with one key, and array of values for that key.

Query string should look like this: ?difficulty[]=beginner&difficulty[]=advanced

Activity icon

Replied to How To Chain Multi Values In Query String?

hm... I belive there is a way to do with links.

Jul
24
3 weeks ago
Activity icon

Replied to How To Chain Multi Values In Query String?

Thanks, but that wouldn't work a job. I dont want both values. I want to make choice, one, two, three... etc values...

For the example, when you choose brands on Amazon, you have choice to "chekched" how many you want. Not one, not all.

Activity icon

Replied to How To Chain Multi Values In Query String?

Yup, but how to pass that array? This is not working. error --- "Cannot use [] for reading"

<a href="{{ route('courses.index', ['difficulty'[]=>'beginner' ]) }}" > Beginner </a>
<a href="{{ route('courses.index', ['difficulty'[]=>'advanced' ]) }}" > Addvanced</a>
Activity icon

Replied to How To Chain Multi Values In Query String?

But how to have both values from same key difficulty. For the example: ?difficulty=beginner&difficulty=advanced

<a href="{{ route('courses.index', [difficulty'=>'beginner' ]) }}" > Beginner </a>
<a href="{{ route('courses.index', [difficulty'=>'advanced' ]) }}" > Addvanced</a>
Jul
21
3 weeks ago
Activity icon

Started a new Conversation Multi Query String Method

Is it better way to achive this. I need 10 queries to chain. It would be too much repetition.

courses?dificulty=advanced&sort=latest

<ul class="nav justify-content-center">
  <li class="nav-item">
    <a class="nav-link " href="#">Dificulty:</a>
    <a href="{{ route('courses.index', ['dificulty'=> 'beginner', 'sort'=> request()->sort]) }}">beginner</a>
    <a href="{{ route('courses.index', ['dificulty'=> 'advanced', 'sort'=> request()->sort]) }}">advanced</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" href="#">Sort:</a>
    <a href="{{ route('courses.index', ['dificulty'=> request()->dificulty,'sort'=> 'latest']) }}">latest</a>
    <a href="{{ route('courses.index', ['dificulty'=> request()->dificulty,'sort'=> 'oldest']) }}">oldest</a>  
  </li>
</ul>
Activity icon

Replied to How To Chain Multi Values In Query String?

This is example; What if I want multi values for dificulty?, or for some products, multi brands?

Activity icon

Replied to How To Chain Multi Values In Query String?

How to make query?

?sort=latest&dificulty=advanced&dificulty=beginner

Activity icon

Started a new Conversation How To Chain Multi Values In Query String?


public function index(Request $request)
    {
        $courses = Course::query();

		if ($request->get('dificulty')){
			$courses->where('dificulty', $request->get('dificulty'));	//?dificulty=beginner
		}

		if ($request->get('dificulty')){
			$courses->where('dificulty', $request->get('dificulty'));	//?dificulty=advanced
		}

		//sorting
		if (request()->sort == 'latest') {
            $courses = $courses->latest()->get();

        } 	elseif (request()->sort == 'oldest') {
            	$courses = $courses->oldest()->get();
        }             
            else {
            	$courses = $courses->get();
        }


		return $courses;
    }
Jul
11
1 month ago
Activity icon

Replied to Strange Behavior

In my db I have a record. I had tried before to redirect, and that is working, even though I deleted it from vue js (window.location)


   //    .then(function (response) {
        //        window.location = response.data.redirect;  
       //                                                 });

//      return ['redirect' => route('reservations.index')];
Activity icon

Started a new Conversation Strange Behavior

Very strange behavior of my app. I have error 404 when i want to store data from vue.js.

createResevation() {


            axios.post('/reservations', this.item);
 
             },


controller:
$data = Reservation::create([
            'user_id' => auth()->user()->id,
            'guest_id' => request('guestsId'),
            'hotel_id' => request('hotelsId'),           
            'adults' => request('value'),
            'children' => request('value2'),
            'start' =>  request()->value1[0],
            'end' =>  request()->value1[1],
            'total' => 10,
            'commission' => "2",          
        ]);     
 
  return $data;