knubbe82

knubbe82

Member Since 1 Year Ago

Belgrade

Web Developer at 42coders

Experience Points 56,090
Experience Level 12

3,910 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 509
Lessons
Completed
Best Reply Awards 5
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

15 Aug
6 days ago

knubbe82 started a new conversation Use Js Class For Map Setup

I want to use class for setting up a map. This is my SmartMap class:

import * as L from "leaflet";

class SmartMap {
    constructor(element, longitude, latitude) {
        this.element = element;
        this.longitude = longitude;
        this.latitude = latitude;
        this.map = function () {
            return L.map(this.element).setView(this.longitude, this.latitude, 13)
        };
    }
}

export default SmartMap

methods of the class is not important. I also set this in app.js:

import SmartMap from './map/Map';
window.SmartMap = SmartMap;

In console, for the this.map method I get this:

map: ƒ ()
arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter (<anonymous>:2:14)]
caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter (<anonymous>:2:14)]
length: 0
name: ""

Does anyone know why and solution for this?

23 Jul
4 weeks ago

knubbe82 started a new conversation Diff Doesn't Working

Can anyone tell me why diff doesn't working. This is what I have:

$users = collect($users)->flatten();
$seminarUsers = $users->unique('id')->diff($meeting->users);
dd($users->unique('id'), $meeting->users, $seminarUsers);

and this is what I have dumped:

Collection {#1414 ▼
  #items: array:9 [▼
    0 => User {#1551 ▶}
    1 => User {#1552 ▶}
    2 => User {#1553 ▶}
    3 => User {#1554 ▶}
    4 => User {#1555 ▶}
    5 => User {#1556 ▶}
    6 => User {#1557 ▶}
    7 => User {#1558 ▶}
    8 => User {#1559 ▶}
  ]
}

Collection {#1384 ▼
  #items: array:1 [▼
    0 => User {#1420 ▶}
  ]
}

Collection {#1389 ▼
  #items: array:9 [▼
    0 => User {#1551 ▶}
    1 => User {#1552 ▶}
    2 => User {#1553 ▶}
    3 => User {#1554 ▶}
    4 => User {#1555 ▶}
    5 => User {#1556 ▶}
    6 => User {#1557 ▶}
    7 => User {#1558 ▶}
    8 => User {#1559 ▶}
  ]
}
15 Jul
1 month ago

knubbe82 left a reply on Managing Mass User Settings

{{ $stream->settings->notes }}

knubbe82 left a reply on Validate Date After And Before

How this (date('H:i:s')) refers to last recorded time attribute?

knubbe82 left a reply on Replacement Of $fillable In Laravel 5.5

You can use

protected $guarded = [];

or to use

$model->attribute = data;
$model->save();

knubbe82 started a new conversation Validate Date After And Before

I have a time field id database and in model I use protected $dates = ['time'];. Before saving a new record I must be sure that new record time is after last record time if that record exist (maybe it's first entry). How can I do that? I try this but it's not working

'time'              => 'required|after:'.$latestTime,
09 Jul
1 month ago

knubbe82 left a reply on How To Add Row Number In Resource?

Dive number 1, Dive number 2, Dive number 3, Dive number 4...

08 Jul
1 month ago

knubbe82 left a reply on Redirecting A Route

Can you share a controller method?

knubbe82 left a reply on Redirecting A Route

return redirect()->route(route_name, ['id' => $restaurant->id]);

knubbe82 started a new conversation How To Add Row Number In Resource?

I have a resource class DiveResource where I have:

<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Carbon\Carbon;

class DiveResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'date_of_diving' => Carbon::parse($this->time)->format('d-m-Y'),
            'date' => Carbon::parse($this->time),
            'time_of_diving' => Carbon::parse($this->time)->format('H:i'),
            'location' => $this->location,
            'bottom_time' => $this->bottom_time,
            'max_depth' => $this->max_depth,
            'water_temp' => $this->water_temp,
            'day_night' => $this->day_night,
            'visibility' => $this->visibility,
            'dive_start' => $this->dive_start,
            'current' => $this->current,
            'tank_type' => $this->tank_type,
            'tank_capacity' => $this->tank_capacity,
            'bar_start' => $this->bar_start,
            'bar_start' => $this->bar_start,
            'bar_end' => $this->bar_end,
            'gas_mix' => $this->gas_mix,
            'belt_weights' => $this->belt_weights,
            'bcd_weights' => $this->bcd_weights,
            'description' => $this->description,
            'user' => $this->user->name,
            'created_at' => $this->created_at->diffForHumans()
        ];
    }
}

I want to add a row number as well but don't know how?

This is my index method in controller where I return this resource:

public function index()
    {
        return DiveResource::collection(auth()->user()->dives()->latest()->paginate(5));
    }

How to add row number in resource?

13 May
3 months ago

knubbe82 left a reply on Validation Date

this is what I need: 'date_of_entry' => 'required|date_format:Y-m-d'

knubbe82 left a reply on Validation Date

@DAVIDPETROV - date did't work for me

knubbe82 started a new conversation Validation Date

How to create validation rules for date format? Right now my app crashes when someone type 5 digits for year. I use default bootstrap date input type element

25 Apr
3 months ago

knubbe82 left a reply on Problem With Confirmation Modal For Delete

@SNAPEY - there is nothing in network

knubbe82 left a reply on Problem With Confirmation Modal For Delete

@TYKUS - I give a action attribute with $('#deleteUserForm').attr('action', '/users/'+id+'');

knubbe82 left a reply on Problem With Confirmation Modal For Delete

@FTIERSCH - Yes I have that input hidden field because I use @method('DELETE')

knubbe82 started a new conversation Problem With Confirmation Modal For Delete

I use modal confirmation for deleting user. This is a button to call a modal:

<a class="btn btn-danger btn-sm" data-toggle="modal" onclick="deleteUser('{{ $user->id }}', '{{ $user->name }}')"><i class="fas fa-trash-alt"></i></a>

This is a modal:

<div class="modal fade" id="deleteUser" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" role="document">
            <div class="modal-content">
                    <div class="modal-header">
                            <h5 class="modal-title"></h5>
                        </div>
                        <div class="modal-body">
                                <strong class="name text-muted"></strong>?
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Izađi</button>
                                 <form method="POST" class="d-inline" id="deleteUserForm">
                                    @method('DELETE')
                                        @csrf
                                        <button type="submit" class="btn btn-danger delete"></button>
                                 </form>
                         </div>
                  </div>
         </div>
 </div>

This is js part

function deleteUser(id, name) {
            $('#deleteUser').modal('show');
            $('.modal-title').text(name);
            $('.name').text(name);
            $('.delete').text('Izbriši');
            $('#deleteUserForm').attr('action', '/users/'+id+'');
            $('.delete').on('click', function () {
                $('#deleteUserForm').submit();
            });
        }

I use resource controller for user and try to use destroy method but I get this error The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE.

Does anyone have a idea, please?

05 Apr
4 months ago

knubbe82 left a reply on Can't Delete Directory With Storage Facade

@MEKADOO - try to provide real path, without storage_path helper

knubbe82 left a reply on Can't Delete Directory With Storage Facade

You don't need this public in url string in storage_path helpers

29 Mar
4 months ago

knubbe82 left a reply on Laravel Homestead With Apache Server

@BRAUNSON - yes, this is what I read also but don't work as I wanted

28 Mar
4 months ago

knubbe82 started a new conversation Laravel Homestead With Apache Server

How to set Homestead for projects that requires Apache server? Right now in Homestead.yaml I only have Laravel projects

25 Mar
4 months ago

knubbe82 left a reply on Do You Use Vim?

Vim is a mother, father and directory of the school :) Little bit difficult to learn but you have a great course here on laracast that will help

19 Mar
5 months ago

knubbe82 started a new conversation Updating Lessons Status In Laracasts Bug?

Does anyone knows why series progress is not updating after completion lesson?

18 Mar
5 months ago

knubbe82 left a reply on Laravel Vue Router Not Working

You don't have mode: 'history' in router.js and <router-view></router-view>

14 Mar
5 months ago

knubbe82 left a reply on Career As A Software Developer

I have already changed my proficiency once in seven years and I do not see the reason why I would not do it again. I'm working as a developer in the agency for 2 years and before that I worked as a finance manager :)

knubbe82 left a reply on How To Check Does Range Times Overlap?

I solve something like this:

public function store(ScheduleStoreFormRequest $request)
    {
        $data = $request->all();

        $data['start'] = Carbon::createFromFormat('d.m.Y H:i', $request->start);
        $data['end'] = Carbon::createFromFormat('d.m.Y H:i', $request->end);

        if (Schedule::count() == 0) {
            return Schedule::create($data);
        }

        foreach (Schedule::all() as $schedule) {
            if (!($data['start'] >= $schedule->end || $schedule->start >= $data['end'])) {
                return ['error_message' => 'There is appointment in that period'];
            }
        }

        return Schedule::create($data);
    }

I also have validation that $data['end'] must be after $data['start']

13 Mar
5 months ago

knubbe82 started a new conversation How To Check Does Range Times Overlap?

I build some patient schedules and I have table where I store patient, start time and end time. I need some kind of validation to check does I already have some patients in that period when I inserting a new patient time.

11 Mar
5 months ago

knubbe82 left a reply on Error Saving Date Format (d/m/Y) To (Y-m-d)

Carbon\Carbon::parse('string')->format('Y/m/d')

15 Feb
6 months ago

knubbe82 started a new conversation Select And Open A Node That Is Just Created (jstree)

I am using jstree to organize groups. I have ALL GROUPS (root node) and children (groups). When I create a group (I am using form) I want to load jstree and automatically open and select newly created group.

This is my code (on load event):

$("#container").jstree().bind("loaded.jstree", function (e, data) {
            var groupId = `{{ $groupId }}`;
        $('#container').jstree(true)._open_to(groupId);

but I can open anything. Does anyone knows solutions?

12 Feb
6 months ago

knubbe82 left a reply on Add New Column To Existing Table

You must define column in Schema::table

knubbe82 left a reply on What Are The Most Common Libraries, Admin Panels Etc That You Use?

Bootstrap is already include in laravel

08 Feb
6 months ago

knubbe82 left a reply on How To Get All Children Recursively?

@STAUDENMEIR - I get relationship in relationship but I need them in same level

knubbe82 left a reply on How To Get All Children Recursively?

@STAUDENMEIR - Still the same. I get only first children but not children of children

knubbe82 started a new conversation How To Get All Children Recursively?

I am trying to get all children of model recursively but can't get children of children. This is what I have:

public function children()
    {
        return $this->hasMany('App\Group', 'parent_id', 'id');
    }

I also try this:

public function childrenRecursive()
    {
        return $this->children()->with('childrenRecursive');
    }

In both cases when I use $group->children or $group->childrenRecursive() I get only children but not children of children.

01 Feb
6 months ago

knubbe82 left a reply on How To Set An Array Globally Available In Laravel?

You can set your arrays in boot method of AppServiceProvider.php something like this:

\Illuminate\Support\Facades\View::composer('*', function ($view) {
$eu = ['germany', 'france'];
            $view->with('some_name', $eu');
        });

this is only for view

31 Jan
6 months ago

knubbe82 left a reply on Call Method From Vue

@PRESMELITO - How to style in component after setup main color in window.App.main_color?

knubbe82 left a reply on I Can Log Email But Can't Send It

@BOBBYBOUWMANN - I find a solution. Instead of sending mail I create a notification and in User.php now I have this:

public function sendPasswordResetNotification($token)
    {
        $this->notify(new MailResetPasswordNotification($token, $this));
    }

and I use email channel in notification

30 Jan
6 months ago

knubbe82 left a reply on I Can Log Email But Can't Send It

@BOBBYBOUWMANN - Yes because all other mails works fine

knubbe82 left a reply on Select Tag With Multiple

<select name="cars[]" multiple>

knubbe82 started a new conversation I Can Log Email But Can't Send It

How is possible that I can log email but can't send it?

User.php

public function sendPasswordResetNotification($token)
    {
        Mail::send(new PasswordResetMail($this, $token));
    }

PasswordResetMail.php

class PasswordResetMail extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public $user;
    public $token;

    /**
     * Create a new message instance.
     *
     * @param $user
     * @param $token
     */
    public function __construct($user, $token)
    {
        $this->user = $user;
        $this->token = $token;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->markdown('emails.reset_password');
    }
}

In .env file I use credential from my mailtrap account

knubbe82 started a new conversation Call Method From Vue

In vue file I have some styling and I need something like this:

p {
    color: {{ MasterData::first()->main_color }}
}

How can I do it?

29 Jan
6 months ago

knubbe82 left a reply on Online School For Web Development

Udemy is a great choice

25 Jan
6 months ago

knubbe82 left a reply on Remove Pivot Table Entries When Deleting Records

$game->players()->detach();

knubbe82 left a reply on Query Problem -> Wrong Data

This is approach that works:

$seminars = Seminar::whereHas('users',function ($query) use ($user) {
                                            $query->where('users.id', $user->id);
                                          })->whereHas('meetings.users', function ($query) use ($user) {
                                            $query->where('user_id', $user->id);
                                            })->with([
                                            'users' => function ($query) use ($user) {
                                                $query->where('users.id', $user->id);
                                            },
                                            'meetings.users' => function ($query) use ($user) {
                                                $query->where('user_id', $user->id);
                                            }])->get();

knubbe82 left a reply on Query Problem -> Wrong Data

@NIKOS - yes but meetings.users must also be like $query->where('meetings.users.id', $user->id) and that's not work

24 Jan
6 months ago

knubbe82 left a reply on Query Problem -> Wrong Data

@NIKOS - I must have meetings and also meetings.users (meetings.users is pivot between users and meetings)

knubbe82 left a reply on Query Problem -> Wrong Data

@CIPSAS - This is not what I except. It's the same like my query but getting wrong date also

knubbe82 started a new conversation Query Problem -> Wrong Data

I know a User but I need to get Seminars with that User and must use something like this: Seminar::with...

This is what I have:

$user = User::findOrFail($request->user_id);
            $seminars = Seminar::with(['users', 'meetings.users'])->whereHas('users', function ($query) use ($user) {
                $query->where('users.id', $user->id);
            })->get();

users and meetings.users are pivot

Problem that I have is 'I receive all users that participate in seminar that specific users also belongs'

How can I solve this?

knubbe82 left a reply on How To Inline Two Components Button In Mail Markdown

After searching for a while best possible solutions is to not use a component. Instead of that, two inline buttons could save your day ;)

23 Jan
6 months ago

knubbe82 left a reply on Invalid Argument Supplied For Foreach()

Need to know what is watchers?