MadMaks

MadMaks

Member Since 8 Months Ago

Berlin

Experience Points
20,680
Total
Experience

4,320 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
199
Lessons
Completed
Best Reply Awards
0
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.

Level 5
20,680 XP
Jun
02
4 months ago
Activity icon

Replied to How Can I Access The Data Properties In A Vue Component

@MAVERICKCHAN - I pass them to the component via props. After that i define them in the data like so:

data() {
            return {
                player: null,
                ID: this.idofvideo,
                hasWatched: this.videoiswatched,
                slugOfVideo: this.slugofvideo,
            }
        },
Jun
01
4 months ago
Activity icon

Replied to How Can I Access The Data Properties In A Vue Component

if i define a variable at the beginning it works, but i still can't update my hasWatched status in my component:(

mounted() {
            let slugvideo = this.slugOfVideo;
            let watchedvideo = this.hasWatched;
            console.log(this.slugOfVideo);
            this.install();
            this.player
                .on("ended", function() {
                    axios({
                        method: 'post',
                        url: '/Video/store/watched',
                        data: {
                            slug: slugvideo,
                        }
                    });
                    if(!watchedvideo){
                        flash('Thanks for watching again!');
                    }
                    if(watchedvideo){
                        flash('Congrats you completed the video!');
                    }
                    this.hasWatched = !this.hasWatched;
                    window.events.$emit('has-watched-video');
                });
        },
ยดยดยด
Activity icon

Replied to How Can I Access The Data Properties In A Vue Component

i tried:

 console.log(this.$parent.slugOfVideo);

but with no success:/

May
31
4 months ago
Activity icon

Started a new conversation How Can I Access The Data Properties In A Vue Component

Hey i want to get the property of my slug, but if use this.slugOfVideo here in this case it returns an undefined in the console.

data() {
            return {
                player: null,
                ID: this.idofvideo,
                hasWatched: this.videoiswatched,
                slugOfVideo: this.slugofvideo,
            }
        },
        methods: {
            install() {
                this.player = new Player( this.$el , {
                    id: 19231868,
                    width: 600,
                });

            }
        },
        mounted() {
            this.install();
            this.player
                .on("ended", function() {
                    console.log(this.slugOfVideo);

How can i access the data from above? With best regards!

Activity icon

Replied to Why Is This Failing??

it was just a silly typo in my function name i didnt see... sry for that.

Activity icon

Started a new conversation Why Is This Failing??

Any guesses why this code is failing? I have no clue why...

use Illuminate\Http\Request;
use App\Reply;
use App\User;
class BestReplyController extends Controller
{
    public function store(Reply $reply)
    {
        abort_if($reply->thread->user_id !== auth()->user()->id, 403);
        
        
        $bestReplyID = $reply->thread->best_reply_id;
        if(!is_null($bestReplyID))
        {
            $bestReply = Reply::where('id', $bestReplyID )->first();
            $user = User::where('id', $bestReply->user_id)->first();
            $user->dewardWith(500);
        }

it gives me an 500 error.

i trigger this endpoint from an axios post request.

May
28
4 months ago
Activity icon

Replied to How Can I Use The With Function In My Authenticate.php

Okay, now i get this error :

ErrorException thrown with message "Header may not contain more than a single header, new line detected"

  if (headers_sent()) {
            return $this;
        }
 
        // headers
        foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
            $replace = 0 === strcasecmp($name, 'Content-Type');
            foreach ($values as $value) {
                header($name.': '.$value, $replace, $this->statusCode);
            }
        }
 
        // cookies
        foreach ($this->headers->getCookies() as $cookie) {
            header('Set-Cookie: '.$cookie->getName().strstr($cookie, '='), false, $this->statusCode);
        }
 
        // status
        header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
 
        return $this;
    }
Activity icon

Started a new conversation How Can I Use The With Function In My Authenticate.php

Hey, I want to use this function like so on my Authenticate.php. What do i have to add?

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Laravel\Cashier\Billable;
use Illuminate\Support\Facades\Auth;

class Authenticate extends Middleware
{
    use Billable;
    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string
     */
    protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
        return route('landingPage')->with('flash','Login to use all of our features');
        }
    }
}

With best regards

May
25
4 months ago
Activity icon

Started a new conversation Vue Data Doesn't Show Up The Correct Way In My View

Hi @all, I want to show the number of Likes in my bladeview and i have no idea why it isn't working.

my vue is looking like that:

new Vue({
              el: '#Like_button_Best_answer',
              data:{
                  likeCount: 120,
                  classObject: {
                      'btn-simple': {{!$reply->favorites()->where(['user_id' => $user->id])->exists()}}
                  }
          },
              methods: {
                  like() {
                      axios.post('/replies/{{$reply->id}}/favorites');
                      this.classObject["btn-simple"] = !this.classObject["btn-simple"];
                      /*vm2.show = true;
                      setTimeout(() => {
                          vm2.show = false;
                      },3000);*/
                  }
              }

          });

and in my blade file added an @ before as described in the documentation.

<div class="card-footer" id="Like_button_Best_answer">

                                                                                    <div class="col-12 pull-right">
                                                                                        <button class="btn btn-primary btn-sm pull-right" v-bind:class="classObject" @click="like">
                                                                                            <i class="tim-icons icon-heart-2"></i> @{{likeCount}}
                                                                                        </button>

for test purposes i hardcoded the 120... but it doesn't work.

it only shows {{likeCount}} in my view.

With best regards

May
21
4 months ago
Activity icon

Replied to Change Data From Another Vue Element

That's what i was looking for :) perfect. Thx

Activity icon

Started a new conversation Change Data From Another Vue Element

How can i change this show data to true if i hit the destroy mehtod of the second element??

<script>
        new Vue({
            el: '#flashMessage',

            data: {
                show: false
            }
        });

    @if($thread->hasReplies())
       new Vue({
            el: '#dropdown-vue',

           methods: {
                destroy() {
                    axios.delete('/replies/{{$reply->id}}/delete');
                }
               }

       });
May
14
5 months ago
Activity icon

Replied to What's Wrong With This?

I think the where filter is wrong and also you don't need to do ->get()->first(), do instead only ->firstOrFail() for example:

$profilelist = DB::table('users')
  ->select('id','name', 'phone', 'email')
  ->where('id' , $userID)
  ->firstOrFail();
Activity icon

Replied to Keep Formatted Text In Database And Display It Correctly

Hmmm, but isn't my site now hackable, because everyone can put html and php code into it????

Activity icon

Replied to Keep Formatted Text In Database And Display It Correctly

okay, i made it work. at least the new Lines.

I replaced the request like this

'body' => nl2br(request('body')),

and then echo it with normal php in the view like this:

<?php echo "{$thread->body}";?>

that works just fine for now.

Activity icon

Started a new conversation Keep Formatted Text In Database And Display It Correctly

Hey, If i save my text in the database and then display it in the the browser it doesn't show me the correct formatting as it was before.

I save it like this:

$thread = Thread::create([
           'title' => request('title'),
            'body' => request('body'),

in the database.

However if I disiplay it within my views, all the new lines etc. are lost.

Thank your for your answers in advance:)

May
10
5 months ago
Activity icon

Replied to Prevent White Flash

Nope, telescope says that it needs about 500ms to load a page. Is that too long? I'm running laragon from a 3.0 usb stick. Could that be the reason?

May
09
5 months ago
Activity icon

Started a new conversation Prevent White Flash

As i clicked through my Homepage, I noticed, that there is some kind of a white flash before the page is fully loaded. Here on Laracasts there is absolutely nothing inbetween the pageloads... It is super smooth. How can i achieve that? With best regards.

May
08
5 months ago
Activity icon

Started a new conversation Cache Invoices

Hi @all, I want to cache invoices for the user, because cashier needs quiet a lot of time to create them. If i do it like this, the problem would be, that all users will have the same invoices, because there is only one key generated for all users right?

if (Cache::has('invoices')) {

                $invoices = Cache::get('invoices');

            }
            if (!Cache::has('invoices')){

                Cache::put('invoices', $user->invoices(), 60*60);
                $invoices = Cache::get('invoices');

            }

how can i fix this?

Best regards, Max

May
02
5 months ago
Activity icon

Started a new conversation Call To Undefined Relationship [videolikes] On Model [App\Videopost].

Hi, i get this error message and don't know why, maybe you could help me out. Thanks in advance.

$productionPosts = Videopost::where('category' , 'Production')
            ->with('videolikes')
            ->get();

this is my user model

public function likesVideo()
    {
        return $this->belongsToMany(Videopost::class , 'videolikes')->withTimestamps();
    }

and this is my videopost model

public function hasVideoLikes()
    {
        return $this->belongsToMany(User::class , 'videolikes')->withTimestamps();
    }
Apr
20
5 months ago
Activity icon

Replied to Select Only Specific Attributes With Eager Loading

Perfect, that is exactly what i wanted to know!!! Thank you :))

Activity icon

Started a new conversation Select Only Specific Attributes With Eager Loading

Hey is it possible to get specific attributes with eager loading, i want to select only one attribute from the role table for example. Thanks in advance:)

$user = User::where('id', auth()->user()->id)
            ->select('name' , 'email', 'created_at','card_last_four','card_brand' , 'trial_ends_at')
            ->with(['roles' , 'subscriptions'])
            ->first();


Mar
30
6 months ago
Activity icon

Replied to Paginate Comments

Change the array with the groupby function wasn't a good idea at all. I found a solution on this page here: https://appdividend.com/2018/06/20/create-comment-nesting-in-laravel/

thanks for your effort

Mar
28
6 months ago
Activity icon

Started a new conversation Paginate Comments

Hey, I can't figure out how to paginate those comments. Every help is welcome :)

 public function show($slug)
    {
        $videoPost = VideoPost::where('slug', $slug)->first();
        if($videoPost->comments()->count()>0) {
            $comments = $videoPost->comments->groupBy('parent_id');
            $comments['root'] = $comments[''];
            unset($comments['']);

Best Regards

Mar
24
6 months ago
Activity icon

Replied to Multiple Post Requests To One Page

@successdav and @diegoaurino thx for your fast repiles:) works fine:)

Activity icon

Started a new conversation Multiple Post Requests To One Page

Hi @all, Is there a simple way, to make two post request with the same action url? Maybe with the id or the name of the forms? I tried this but it doesn't work:(

Route::post('/Video/{slug}' , ['video-comment' , 'uses' => '[email protected]']);
    Route::post('/Video/{slug}' , ['video-like' , 'uses' => '[email protected]'] );

and my forms look like this:

<form method="POST" action="/Video/{{$videoPost->slug}}" id="video-like" name="video-like">
    {{csrf_field()}}
        <button type="submit">Like</button>
    </form>

Thanks in advance for any replies:)

Mar
22
6 months ago
Activity icon

Started a new conversation How Can I Refactor This Queries To Get The Number Of Specific Users

Hey, is there a better way to refactor this queries? The way i did it is working but i don't think it is very smart. Any ideas?

//counts
        $PremiumUser = User::whereHas("roles", function($q){ $q->where("name", "Premium-Subscriber"); })->count();
        $Subscriber = User::whereHas("roles", function($q){ $q->where("name", "Subscriber"); })->count();
        $NewUser = User::whereDate('created_at','>=', date('Y-m-d H:is',strtotime('-7 days')))->count();


        return view('users.index', compact('users', 'PremiumUser' , 'Subscriber' , 'NewUser'));

Thanks in advance :)