honeyBear

honeyBear

Member Since 2 Months Ago

Experience Points
5,640
Total
Experience

4,360 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
36
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 2
5,640 XP
Oct
14
2 days ago
Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

No, the game server only provide POST request to the uri inside the cfg game file. So Im expecting that maybe the way Im implementing on the laravel backend side is wrongly. Hmm

Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

Just checked it, nothing as well. Any ideas why?

Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

There are no post request to my laravel server, as I checked my gameserver log files. Mhmm I dont know why but I feel like the way I code is wrong tho >.>

Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

Hi there I'm finally trying your suggestion approach. Heres how I do it, but still I will get error

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException The GET method is not supported for this route. Supported methods: POST.

Am I implementing this all totally wrong?

(web.php)

Route::post('/livescores', '[email protected]');

([email protected])

    public function index(Request $request)
    {
    $uri = $request->path('http://rentap.test/livescores:80');
        $livedata = json_decode($uri->getBody(), true);
        $livedata->data['map'];
        dd($livedata);
    }

(Game Server File Cfg)

"CSGO HUD"
{
 "uri" "http://rentap.test/livescores:80"
 "timeout" "5.0"
 "buffer"  "0.1"
 "throttle" "0.1"
 "heartbeat" "60.0"
 "data"
 {
   "provider"            "1"
   "map"                 "1"
   "round"               "1"
   "player_id"           "1"
   "player_state"        "1"
   "player_weapons"      "1"
   "player_match_stats"  "1"
   "allplayers_match_stats"  "1"
 }
}

(Laragon Vhost File)

<VirtualHost *:80> 
    DocumentRoot "E:/Laragon/www/rentap/public/"
    ServerName rentap.test
    ServerAlias *.rentap.test
    <Directory "E:/Laragon/www/rentap/public/">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

Alright thanks for the solution!! I'll try again tonight :D I'll update this post on how it goes. Nah its not even production yet, so its okay :)

Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

can you help me personally? i have teamspeak and teamviewer if youre free to come over explain and guide it to me.. confused now, trying to listen and get live data from the server or else i cant do other core functionalities for my web application..

Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

for my case i need to use api.php? I'm using routes web.php.

Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

By rights once I start the game server and let my friends try then make the server game match live, It should send some data to my web application right?

Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

The user made the request through my web application to websocket.test/data . I dont know if I'm making the right routes for this, like you said i need to make a post routes in my web in order to get what the server trying to send me using that uri right? Or im confused of how you explain it to me.

Activity icon

Replied to How Do I Listen To A Server Port In Laravel?

I tried but I got a Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException The GET method is not supported for this route. Supported methods: POST.

(routes web,php)

Route::post('/data',  '[email protected]')->name('store');

([email protected])

    public function store(Request $request)
    {
        $payLoad = json_decode(request()->getContent(), true);
        dd($payLoad);
    }

(servercfg file)

"CSGO HUD"
{
 "uri" "http://websocket.test/data"
 "timeout" "5.0"
 "buffer"  "0.1"
 "throttle" "0.1"
 "heartbeat" "60.0"
 "data"
 {
   "provider"            "1"
   "map"                 "1"
   "round"               "1"
   "player_id"           "1"
   "player_state"        "1"
   "player_weapons"      "1"
   "player_match_stats"  "1"
   "allplayers_match_stats"  "1"
 }
}

I am using laragon to serve the laravel application.

Oct
13
3 days ago
Activity icon

Started a new conversation How Do I Listen To A Server Port In Laravel?

Hi, I'm quite new with laravel. I have a question, how do I listen to a server port in my laravel web application? Currently, I have a dedicated game server that I would like to listen to in order to get live data from it. Maybe save couples of data such as game score in my db.

How this work? The game server have a game state integration implementation that could send payload of game data by configuring the game state integration file in the server cfg folder. Here are the further explaination https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Game_State_Integration . Further explaination by reddit a user https://www.reddit.com/r/GlobalOffensive/comments/cjhcpy/game_state_integration_a_very_large_and_indepth/

Done some research how I could achieve this with socket.io, If i am correct. However, im still not getting clear explaination whether if I needed to use pusher or redis for this type of situation? So any ideas or approach how I can communicate with the game server? Any rough idea is appreciated tho.. currently stuck on how to dos. Thank you..

Here are example using expressjs and node for what im trying to achieve https://github.com/Double0negative/CSGO-HUD

Oct
10
6 days ago
Activity icon

Replied to How To Render Tournament Bracket For Next Round

I checked your suggestion from the stackoverflow, however I already have design the tournament bracket. Maybe my post wasn't clear. Its just how do I render the next stage automatically using backend in laravel. Above code was I manage to arrange player who they fight in the first round. Do I need to hardcode for the next stages?

Activity icon

Replied to Trying To Hide Button In Blade

Ohh just know about that, thank you :)

Activity icon

Replied to Trying To Hide Button In Blade

Nvm silly me, changed it to below. LOL @honeybear

@if(count($post->teams) < $post->size)
   <a href="/team/register/post/{{$post->id}}" class="btn btn-outline-dark btn-sm">
         {{ __('Register') }}
    </a>
@elseif($team['id'] != auth()->user()->team['id'])
    <a href="/team/register/post/{{$post->id}}" class="btn btn-outline-dark btn-sm">
           {{ __('Register') }}
    </a>
@else
                                    
@endif
Activity icon

Started a new conversation Trying To Hide Button In Blade

I have problems on trying to hide button, below are the condition that I have set in order to display or not to display the button. Either way i still cant hide the button if I use elseif. Any solutions?

<!--if number of teams in pivot table less size of team slot in tournament post user can see the button else can't--> 
@if(count($post->teams) < $post->size)
     <a href="/team/register/post/{{$post->id}}" class="btn btn-outline-dark btn-sm">
          {{ __('Register') }}
     </a>
@else

@endif

<!--if team id in pivot table is same with user team id user can't see the button else can-->
@if($team['id'] == auth()->user()->team['id'])

@else
     <a href="/team/register/post/{{$post->id}}" class="btn btn-outline-dark btn-sm">
          {{ __('Register') }}
     </a>
@endif
Oct
09
1 week ago
Activity icon

Replied to Register A Team To A Post

Thank you for those who give my suggestion and ideas :)

Activity icon

Replied to Register A Team To A Post

Oh yea I forgot to remove it bcs I copy paste a form from create post so yea it consist of some file uploading. Ill remove it later. Again, thank you nakov :)

Activity icon

Replied to Register A Team To A Post

Thank you guys for the ideas and approach :) However I did a little changed, because I still cant see the flow, Here's how I store the data into the pivot table that enable me to understand more the flow. I created another controller name TeamRegistersController and made a little change up on the endpoint of the button. As well as in my routes. What do you guys think? Its a little bit more of work I guess.

(post show.blade.php)

<a href="/team/register/post/{{$post->id}}" class="btn btn-outline-dark btn-sm">
      {{ __('Register') }}
</a>

(registerteams create.blade.php)

<form method="post" action="/team/register" enctype="multipart/form-data">
    @csrf
    <input type="hidden" name="post_id" value="{{$post->id}}" >
    <input type="hidden" name="team_id" value="{{$team->id}}" >
    <div class="form-group">
       <label>Team</label>
        <select class="form-control" name="team_id" required>
               <option selected disabled>Pick Team</option>
               @foreach($teams as $team)
                   <option value="{{$team->id}}">{{$team->name}}</option>
                @endforeach
         </select>
          <small class="form-text text-muted">Your event team</small>
      </div>
      <div class="form-group row mb-0">
           <div class="col-md-6">
              <button type="submit" id="btn-spinner" class="btn btn-outline-dark btn-sm">
                 {{__('Submit') }}
              </button>
              <a href="/home" class="btn btn-outline-dark btn-sm">
                 {{ __('Back') }}
              </a>
           </div>
      </div>
</form>

(web.php)

Route::get('/team/register/post/{post}', '[email protected]');
Route::post('/team/register', '[email protected]');

(teamregisterscontroller)

    public function create(Post $post, Team $team)
    {
        $teams = Team::where('user_id', '=', auth()->user()->id)->get();

        return view('teamregisters.create',[
            'teams' => $teams,
            'post' => $post,
            'team' => $team
        ]);
    }

    public function store(Request $request)
    {
        $team = Team::find(request('team_id'));
        $post = Post::find(request('post_id'));
        $post->teams()->attach($team);

        return redirect('/home')->with('success', 'Team Registered');
    }
Activity icon

Replied to Register A Team To A Post

Yes my relationship between user and team is that i have restricted that a user can only have one team. So therefore the relationship i have declare inside both model User and Team is User hasOne team and Team belongsTo user. I know that my form doesn't have post->id and team->id that i wanted to pass to the register() method, its just how do I passed a hidden value of post->id and team->id ? :S

Activity icon

Replied to Register A Team To A Post

I'm sorry, I forgot to mention. The $post->id comes from the current show.blade.php of current post id. But I'm not sure how to pass the current post->id and team->id in the form. The form is located inside show.blade.php. I have update this thread where I include the [email protected] I'm quite confused.

Activity icon

Started a new conversation Register A Team To A Post

Currently, I am trying to register Team to a Post. Team belongstoMany Post and Post belongstoMany Team. But the data is not stored into the pivot table, am I doing it the wrong way? Below is my code. Assume that user has already created his/her Team before registering his/her Team to desire Post which is a tournament event.

(blade file posts.show)

<form method="post" action="/team/register">
   @csrf
   <a class="btn btn-outline-dark btn-sm">
          {{ __('Register') }}
   </a>
</form>

(routes file)

Route::post('/team/register', '[email protected]');

([email protected])

    public function register()
    {
        $post = Post::find('id', '=', $post->id);
        $team = Team::where('id', '=', $team->id);
        $post->teams()->attach($team);

        return redirect()->back()->with('success', 'Team Registered');
    }

([email protected])

    public function show(Post $post, Bracket $bracket)
    {
        return view('posts.show', [
            'post' => $post,
            'bracket' => $bracket,
        ]);
    }

(pivot table migration file)

    public function up()
    {
        Schema::create('post_team', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('team_id');
            $table->unsignedBigInteger('post_id');
            $table->timestamps();
        });
    }
Activity icon

Replied to How To Render Tournament Bracket For Next Round

Thank you for your suggestion and reply, I'll look at it in a moment. Thought none would have reply to this type of question because i think it is somehow kind of old school type of project (making tournament bracket), because currently I'm stuck on rendering the next stage of the bracket..

Oct
08
1 week ago
Activity icon

Replied to How To Access And Manipulate Pivot Table

Hey man, i tried doing it like this:

public function showUserLikesData() {
        
        $users = User::all();

        $counter = 0;
        $countUser = 0;
        $countThatCategory = 0;
        $categoryName = '';

        foreach($users as $user) {

            $userLikesData[$countUser]['User Id'] = $user->id;

            foreach ($user->likeCategories as $likeCategory) {

                 $categoryName = $likeCategory->pivot->category_name;
                    
                foreach ($user->likeCategories as $likeCategory) {
                    $checkCategoryName = $likeCategory->pivot->category_name;
    
                    if ($categoryName == $checkCategoryName) {
                           $countThatCategory++;
                    }
                }
        
                $userLikesData[$countUser]['Like Categories'][$counter]['Category'] = $categoryName;
                $userLikesData[$countUser]['Like Categories'][$counter]['Amount'] = $countThatCategory;

                $countThatCategory = 0;
                    
                $counter++;
            }
            $countUser++;
            $counter=0;
        }

        return $userLikesData;
    }

But it returns this output:

[
    {
        "User Id": 1,
        "Like Categories": [
            {
                "Category": "Chinese Restaurant",
                "Amount": 1
            },
            {
                "Category": "Korean Restaurant",
                "Amount": 2
            },
            {
                "Category": "Korean Restaurant",
                "Amount": 2
            },
            {
                "Category": "Fast Food Restaurant",
                "Amount": 3
            },
            {
                "Category": "Fast Food Restaurant",
                "Amount": 3
            },
            {
                "Category": "Fast Food Restaurant",
                "Amount": 3
            },
            {
                "Category": "Italian Restaurant",
                "Amount": 1
            },
            {
                "Category": "Steakhouse",
                "Amount": 3
            },
            {
                "Category": "Steakhouse",
                "Amount": 3
            },
            {
                "Category": "Steakhouse",
                "Amount": 3
            }
        ]
    },
    {
        "User Id": 2,
        "Like Categories": [
            {
                "Category": "Thai Restaurant",
                "Amount": 1
            },
            {
                "Category": "Kebab Shop",
                "Amount": 3
            },
            {
                "Category": "Kebab Shop",
                "Amount": 3
            },
            {
                "Category": "Kebab Shop",
                "Amount": 3
            },
            {
                "Category": "Pizza Place",
                "Amount": 2
            },
            {
                "Category": "Pizza Place",
                "Amount": 2
            },
            {
                "Category": "Steakhouse",
                "Amount": 1
            }
        ]
    }
]
Oct
07
1 week ago
Activity icon

Started a new conversation How To Access And Manipulate Pivot Table

I have two tables, users and like_categories which has many-to-many relationship. The pivot table is called like_category_user. After inserting two users data into the db, here is my pivot table look like: https://i.imgur.com/MeeRbiV.png .

Im a little bit confused on how can i access the pivot table since I didnt create a custom model for that pivot table. I want to count the amount for each of the different like category for each user and store it in object array like this:

[
    {
        "User Id": 1,
        "Like Categories": [
            {
                "Category": Chinese Restaurant
                "Amount": 1
            },
            {
                "Category": Korean Restaurant
                "Amount": 2
            },
            {
                "Category": Fast Food Restaurant
                "Amount": 3
            },
            {
                "Category": Italian Restaurant
                "Amount": 1
            },
            {
                "Category": Steakhouse Restaurant
                "Amount": 3
            }
        ]
    },
    {
        "User Id": 2,
        "Like Categories": [
            {
                "Category": Thai Restaurant
                "Amount": 1
            },
            {
                "Category": Kebab Shop
                "Amount": 3
            },
            {
                "Category": Pizza Place
                "Amount": 2
            },
            {
                "Category": Steakhouse
                "Amount": 1
            }
        }
    }
]

My process method:

public function showUserLikesData() {
    //
}
Oct
06
1 week ago
Activity icon

Started a new conversation How To Render Tournament Bracket For Next Round

Hi there, I would like to ask ideas on approaches on how to render tournament bracket for next round. For now I can render the first round but I am not sure how to render the next round bracket. Current output that I get https://i.imgur.com/X5iL6sw.png . The output that I wanted is something like this https://i.imgur.com/Zi3ytgl.png . For now the only approach I can think of hardcode the next round bracket which basically not an ideal approach.

([email protected])

        if($bracket->type == "Single Elimination")
        {
            $numOfParticipant = $bracket->size;
            $rounds = ceil(log($numOfParticipant)/log(2));
            $bracketSize = pow(2, $rounds);
            $requiredByes = $bracketSize - $numOfParticipant;

            if($numOfParticipant<2)
            {
                return [];
            }

            $matches = array(array(1,2));

            for($round=1; $round<$rounds; $round++)
            {
                $roundMatches = [];
                $sum = pow(2, $round + 1) + 1;

                foreach($matches as $match)
                {
                    $teamA = $this->changeIntoBye($match[0], $numOfParticipant);
                    $teamB = $this->changeIntoBye($sum - $match[0], $numOfParticipant);
                    $roundMatches[] = array($teamA, $teamB);
                    $teamA = $this->changeIntoBye($sum - $match[1], $numOfParticipant);
                    $teamB = $this->changeIntoBye($match[1], $numOfParticipant);
                    $roundMatches[] = array($teamA, $teamB);
                }

                $matches = $roundMatches;
            }

dd($matches, $bracketsize, $rounds, $numberofteams, $sum);

public function changeIntoBye($seed,  $numOfParticipant)
    {
        return $seed <= $numOfParticipant ?  $seed : null;
    }

(brackets.show)

<div class="round r-of-2-se-4">
    @foreach($matches as $match)
        <div class="bracket-game">
                <div class="player top">
                 &nbsp;&nbsp;
                 <div class="score">
                   0
                 </div>
            </div>
            <div class="player bot">
                 &nbsp;&nbsp;
                 <div class="score">
                  0
                 </div>
             </div>
         </div>
     @endforeach
</div>

(example of dd result of matches if numOfParticipant = 4)

array:2 [▼
  0 => array:2 [▼
    0 => 1
    1 => 4
  ]
  1 => array:2 [▼
    0 => 3
    1 => 2
  ]
]
4.0
2.0
4
5

(example of bracket hardcode for numOfParticipant = 4)

<div class="round r-of-2-se-4">
                                    <div class="bracket-game">
                                        <div class="player top">
                                            &nbsp;&nbsp;
                                            <div class="score">
                                                0
                                            </div>
                                        </div>
                                        <div class="player bot">
                                            &nbsp;&nbsp;
                                            <div class="score">
                                                0
                                            </div>
                                        </div>
                                    </div>
                                    <div class="bracket-game">
                                        <div class="player top">
                                            &nbsp;&nbsp;
                                            <div class="score">
                                                0
                                            </div>
                                        </div>
                                        <div class="player bot">
                                            &nbsp;&nbsp;
                                            <div class="score">
                                                0
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="connectors r-of-1-se-4">
                                    <div class="top-line"></div>
                                    <div class="clear"></div>
                                    <div class="bottom-line"></div>
                                    <div class="clear"></div>
                                    <div class="vert-line"></div>
                                    <div class="clear"></div>
                                    <div class="next-line"></div>
                                    <div class="clear"></div>
                                </div>

                                <div class="round r-of-1-se-4">
                                    <div class="bracket-game">
                                    <div class="player top">
                                        &nbsp;&nbsp;
                                        <div class="score">
                                            0
                                        </div>
                                    </div>
                                    <div class="player bot">
                                        &nbsp;&nbsp;
                                        <div class="score">
                                            0
                                        </div>
                                    </div>
                                </div>
Oct
05
1 week ago
Activity icon

Replied to How To Access And Manipulate JSON Array Elements

thanks dude :) Is it possible for me to insert each of the data into db inside the loop??

Activity icon

Replied to How To Access And Manipulate JSON Array Elements

hey man, i try to use this concept but it is not working :(

Activity icon

Started a new conversation How To Access And Manipulate JSON Array Elements

Can someone teach me how can i access each of the category element in the data array?? PS: I post this JSON using Postman and try to manipulate it in a Laravel project controller method.

JSON:

{
  "id": "126612213872902",
  "name": "Jack Daniel",
  "likes": {
    "data": [
      {
        "category": "Steakhouse",
        "id": "330668300343348"
      },
      {
        "category": "Ice Cream Shop",
        "id": "545851225458015"
      },
      {
        "category": "Fast Food Restaurant",
        "id": "24540959832"
      },
      {
        "category": "Korean Restaurant",
        "id": "388180681558608"
      },
      {
        "category": "Chinese Restaurant",
        "id": "288066224573571"
      },
      {
        "category": "Steakhouse",
        "id": "276973702580"
      }
    ]
  }
}

My controller method:

public function requestStore(Request $request) {

        //
}
Oct
04
1 week ago
Activity icon

Replied to Creating Tournaments With Teams, Invites, Bracket Generator Etc..

I was wondering if I could email you asking about tournament bracket. I'm trying to design the bracket logic for now.

Oct
03
1 week ago
Activity icon

Replied to Remove/hide Post_id That Has Been Created In Select Option

Ohh I see, thank you for the clear explaination. I dont even know the doesntHave( ) exist in the documentation. Which part is it in the documentation?

Activity icon

Replied to Remove/hide Post_id That Has Been Created In Select Option

Yes the relationship is like that, as for now Im trying to check if there is post_id in the bracket table which is the same with the post id in the post table then i will display a disable in the option however I dont think my approach is correct, Ill try using doesntHave() first :)

Activity icon

Started a new conversation Remove/hide Post_id That Has Been Created In Select Option

I wanted to hide or remove the post_id value that has been created in the select option value. Any ideas how I can approach this?

(create.blade.php)

<div class="form-group">
   <label>Post</label>
   <select class="form-control" name="post_id" required>
       <option selected disabled>Pick Tournament</option>
       @foreach($posts as $post)
           <option value="{{$post->id}}">{{$post->title}}</option>
       @endforeach
    </select>
    <small class="form-text text-muted">Your tournament type</small>
</div>

(bracket migration)

        Schema::create('brackets', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('post_id');
            $table->unsignedBigInteger('user_id');
            $table->string('type');
            $table->string('size');
            $table->timestamps();
            $table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });

(post migration)

        Schema::create('posts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id');
            $table->string('title');
            $table->mediumtext('description');
            $table->decimal('prize');
            $table->string('location');
            $table->string('image');
            $table->string('type');
            $table->string('size');
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });

Example if I have picked the first value in the select option, when next time I created a new one. I want it to be remove from the select option list. How do I filter it?

https://i.imgur.com/doXSWWR.jpg

Oct
02
2 weeks ago
Activity icon

Replied to How To Update Select Option Input Form

thank you nakov :)

Activity icon

Replied to How To Update Select Option Input Form

I have figured it out, heres the solution.

                    <div class="form-group">
                            <label>Type</label>
                            <select class="form-control" name="type">
                                <option selected>Pick Type</option>
                                <option value="Swiss System" {{($post->type === 'Swiss System') ? 'Selected' : ''}}>Swiss System</option>
                                <option value="Single Elimination" {{($post->type === 'Single Elimination') ? 'Selected' : ''}}>Single Elimination</option>
                                <option value="Double Elimination" {{($post->type === 'Double Elimination') ? 'Selected' : ''}}>Double Elimination</option>
                            </select>
                            <small class="form-text text-muted">Your tournament type</small>
                        </div>
                        <div class="form-group" >
                            <label>Participant</label>
                            <select class="form-control" name="size">
                                <option selected>Pick Size</option>
                                <option value="2" {{($post->size === '2') ? 'Selected' : ''}}>2</option>
                                <option value="4" {{($post->size === '4') ? 'Selected' : ''}}>4</option>
                                <option value="8" {{($post->size === '8') ? 'Selected' : ''}}>8</option>
                                <option value="16" {{($post->size === '16') ? 'Selected' : ''}}>16</option>
                                <option value="32" {{($post->size === '32') ? 'Selected' : ''}}>32</option>
                            </select>
                            <small class="form-text text-muted">Your tournament size</small>
                        </div>
Activity icon

Started a new conversation How To Update Select Option Input Form

Currently I have success on storing the select option in my input form. How do I get the select option value to be display inside my edit form?

(edit.blade.php)

<div class="form-group">
    <label>Type</label>
    <select class="form-control" name="type">
        <option selected>Pick Type</option>
        <option value="Swiss System">Swiss System</option>
        <option value="Single Elimination">Single Elimination</option>
        <option value="Double Elimination">Double Elimination</option>
    </select>
    <small class="form-text text-muted">Your tournament type</small>
</div>

<div class="form-group" >
   <label>Participant</label>
   <select class="form-control" name="size">
       <option selected>Pick Size</option>
       <option value="2">2</option>
       <option value="4">4</option>
       <option value="8">8</option>
       <option value="16">16</option>
       <option value="32">32</option>
   </select>
   <small class="form-text text-muted">Your tournament size</small>
</div>

([email protected])

$post->type = $request->input('type');
$post->size = $request->input('size');
$post->save();
Sep
30
2 weeks ago
Activity icon

Replied to How To Store Select Option Input Type In Form

ohh thats why in the docs https://laravel.com/docs/4.2/schema#adding-columns example give an array value.

$table->enum('choices', array('foo', 'bar'));

thank u for the deets.

Activity icon

Replied to How To Store Select Option Input Type In Form

ohhh damnit, didn't notice that. what a silly mistake. thank you for pointing that out :S ahh i see, is there any specific case if I were to use enum?

Activity icon

Replied to How To Store Select Option Input Type In Form

ohhh damnit, didn't notice that. what a silly mistake. thank you for pointing that out guys. :S

Activity icon

Started a new conversation How To Store Select Option Input Type In Form

Right now, I am trying to store value from select option form into my database, how can I achieve this? And are they any difference if I'm using type enum or integer in schema for input form select option?

(create.blade.php)

<div class="form-group">
     <label>Type</label>
     <select class="form-control" name="type">
         <option selected>Pick Type</option>
         <option value="swiss">Swiss System</option>
         <option value="single">Single Elimination</option>
         <option value="double">Double Elimination</option>
     </select>
     <small class="form-text text-muted">Your tournament type</small>
 </div>

 <div class="form-group" name="size">
      <label>Participant</label>
      <select class="form-control">
           <option selected>Pick Size</option>
           <option value="2">2</option>
           <option value="4">4</option>
           <option value="8">8</option>
           <option value="16">16</option>
           <option value="32">32</option>
      </select>
      <small class="form-text text-muted">Your tournament size</small>
</div>

([email protected])

    public function store(Request $request)
    {
        $this->validate($request, [
            'type' => 'required',
            'size' => 'required',
        ]);
        
        $post = new Post();
        $post->user_id = auth()->user()->id;
        $post->type = $request->input('type');
        $post->size = $request->input('size');
        $post->save();
        
        return redirect('/posts')->with('success', 'Post Created');
    }

(schema)

Schema::create('posts', function (Blueprint $table) {
   $table->bigIncrements('id');
   $table->unsignedBigInteger('user_id');
   $table->string('type');
   $table->string('size');
   $table->timestamps();
   $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
Activity icon

Replied to How Do I Show Other User Profile

Haha yeah, I do said it out loud when doing relationship between models. Thank you for teaching :)

Sep
29
2 weeks ago
Activity icon

Replied to Profile Not Showing User Profile Image

Ohh i see, thank you for the advice and solution. It works :-)

Activity icon

Started a new conversation Profile Not Showing User Profile Image

I'm trying to display each user profile image from my public/storage/profile_images. These are the approach that I have tried. I tried using normal src="storage/profiles_image/{{$profile->image}}" but that don't work either.

(profile.show.blade.php)

<img src="{{asset('storage/profiles_image/$profile->image')}}" class="img-thumbnail" width="208" height="208">
<!--<img src="storage/profiles_image/{{$profile->image}}" class="img-thumbnail" width="208" height="208">-->
Activity icon

Replied to How Do I Show Other User Profile

Yes a profile does belongsTo a user, thank you for your help. Im still confuse how relationship works backwards? can u explain it to me. Because in my mind, i did not relate any relationship for post and profile. So in my mind was, I have to use /profile/{{profile->id}}. Your solution works btw.

Activity icon

Started a new conversation How Do I Show Other User Profile

I'm trying to get user to view other user profile from the link in posts.show.blade.php, how do I achieve this?

(profile.show.blade)

<html>
    <head>
    </head>
    <body>
        <b>Name:</b> {{$profile->user->name}} <br/>
        <b>Email:</b> {{$profile->user->email}} <br/>
        <b>Description:</b> {{$profile->description}} <br/>
        <b>Location:</b> {{$profile->city}}, {{$profile->state}} <br/>
    </body>
</html>

(posts.show.blade.php)

<a href="">{{$post->user->name}}</a>

(routes web.php)

Route::get('/profile/{profile}', '[email protected]');

([email protected])

    public function show(Post $post)
    {
        return view('posts.show', [
            'post' => $post,
        ]);
    }

([email protected])

    public function show(Profile $profile)
    {
        return view('profiles.show', [
            'profile' => $profile
        ]);
    }
Sep
27
2 weeks ago
Activity icon

Started a new conversation Disable Guzzle From Doing A Get Request With Specific Condition

For now I have success on integrating API in my web application, by taking portion of the data retrieve from the API such as steamid I can make a get request using guzzle to get other data such as game stats to display on my user profile.

By rights in my web application, a user can access the /profile routes to edit or connect to their steam account to get other data such as game stats to be display on their profile https://i.imgur.com/CWYL8xB.png . Example screenshot of user that have already integrate their account https://i.imgur.com/KViazYi.png . Example of error when going to the /profile routes https://i.imgur.com/Ob0rOgN.png

However, if a registered new user which havent connect their steam account in order to get the other data such as game stats. An error is display from the guzzle function. Is there any approach I can take to make a specific condition like if a user havent connect their steam account, dont do the get request from guzzle function? Or other nice approach that I can follow, is appreciated.

(Steam controller)

    public function handleProviderCallback($provider, Steam $steam)
    {
        $data = Socialite::driver($provider)->user();

        $steam = new Steam();
        
        $steam->user_id = auth()->user()->id;
        $steam->profile_id = auth()->user()->profile->id;
        $steam->steamid = $data->user['steamid'];
        $steam->profileurl = $data->user['profileurl'];
        $steam->save();

        return redirect('/home')->with('success', 'Steam Connected');
    }

(Steam model)

    public static function steamProfile()
    {   
        $client = new \GuzzleHttp\Client(['verify' => false]);

        $response = $client->request('GET', 
        'https://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/', [
            'query' => [
                'appid'=>'730',
                'key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
                'steamid' => auth()->user()->steam['steamid']
            ],
        ]);
        
        $data = json_decode($response->getBody(), true);
        return $data;
    }

(Profile Controller @index)

    public function index(Steam $steam)
    {   
        $data = Steam::steamProfile();
        
        return view ('profiles.index', [   
            'data' => $data,
            'profile' => Auth::user()->profile,
            'steam' => Auth::user()->$steam
        ]);
    }

(Profile index.blade.php)

<div class="card-header">
   Profile Dashboard
   <div class="float-right">
       @if(is_null(auth()->user()->steam))
        <a href="/login/steam" class="btn btn-outline-dark btn-sm">
            {{ __('Connect Steam') }}
            </a>
            <a href="/profile/{{$profile->id}}/edit" class="btn btn-outline-dark btn-sm">
            {{ __('Edit Profile') }}
            </a>
       @else
            <a href="/profile/{{$profile->id}}/edit" class="btn btn-outline-dark btn-sm">
            {{ __('Edit Profile') }}
            </a>
        @endif
   </div>
</div>

<div class="container">
    <div class="row">
         <div class="col-3 pl-5">
          <br/>
          @if(is_null($profile->image))
              <img src="/jpg/default.jpg" class="img-thumbnail" width="208" height="208">
          @else 
              <img src="storage/profiles_image/{{$profile->image}}" class="img-thumbnail" width="208" 
              height="208">  
          @endif
     </div>
     <div class="col-9">
     <br/>
     <b>{{$profile->username ?? 'No Information'}}</b><br/>
     <br/>
     <div class="h7 text-muted">{{$profile->description ?? 'No Information'}}</div>
     <br/>
     <b>{{$profile->city ?? 'City'}}</b>, <b>{{$profile->state ?? 'State'}}</b> <br/>
     <br/>
     <b>Following:</b> 0&nbsp;&nbsp;&nbsp;<b>Followers:</b> 0
  </div>
 </div>
</div>
             
<div class="container pt-4">
   <table class="table table-bordered">
      <tbody>
        <tr>
            <th class="card-header" colspan="2"></th>
        </tr>
        <tr>
            <th scope="row" width="50%">steam_id</th>
            <td>{{$profile->steam->steamid ?? 'No Information'}}</td>
        </tr>
        <tr>
            <th scope="row">steam_url</th>
            <td>{{$profile->steam->profileurl ?? 'No Information'}}</td>
        </tr>
     </tbody>
   </table>
</div>

<div class="container pt-2">
   <table class="table table-bordered">
       <tbody>
          <tr>
             <th class="card-header" colspan="2"></th>
          </tr>
          @foreach($data as $stats)
                 @foreach($stats['stats'] as $stat)
                        <tr>
                            <th scope="row" width="50%">{{$stat['name'] ?? 'No Information'}}</th>
                            <td>{{$stat['value'] ?? 'No Information'}}</td>
                        </tr>
                 @endforeach
         @endforeach
         </tbody>
    </table>
</div>
Sep
26
2 weeks ago
Activity icon

Replied to Display Json In Blade

I rechecked some of my codes and your suggestion works.

Activity icon

Replied to Display Json In Blade

Same error results tho, thank you for the replying on trying to help :-)

Activity icon

Started a new conversation Display Json In Blade

Undefined variable: data (View: E:\Laragon\www\rentap\resources\views\profiles\index.blade.php).

For now I am trying to display the data array that I am requesting from the api server. How can I achieve this tho? Below are the methods that I have tried. Would like to display the stats and achievements.

Laravel 5.8/Guzzle 6.0

(profiles.index)

{{$data->playerstats}}
@foreach($data->stats as $stats)
{{$stats->name}}
{{$stats->value}}
@endforeach

(steamcontroller)

class SteamController extends Controller
{
    public function redirectToProvider($provider)
    {
        return Socialite::with($provider)->redirect();
    }

    public function handleProviderCallback($provider, Steam $steam)
    {
        $data = Socialite::driver($provider)->user();

        $steam = new Steam();

        $steam->user_id = auth()->user()->id;
        $steam->profile_id = auth()->user()->profile->id;
        $steam->steamid = $data->user['steamid'];
        $steam->profileurl = $data->user['profileurl'];
        $steam->save();

        return redirect('/home')->with('success', 'Steam Connected');

    }

    public function showData()
    {
        $client = new \GuzzleHttp\Client(['verify' => false]);

        $response = $client->request('GET', 'https://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/', [
            'query' => [
                'appid'=>'730',
                'key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
                'steamid' => auth()->user()->steam['steamid']
            ],
        ]);

        $data = json_decode($response->getBody()->getContents('playerstats'));
        
        dd($data);

        return view('profiles.index',[
            'data' => $data
        ]);
    }

(dd $data)

{#651 ▼
  +"playerstats": {#278 ▼
    +"steamID": "76561198044179316"
    +"gameName": "ValveTestApp260"
    +"stats": array:214 [▶]
    +"achievements": array:167 [▶]
  }
}
{#651 ▼
  +"playerstats": {#278 ▼
    +"steamID": "76561198044179316"
    +"gameName": "ValveTestApp260"
    +"stats": array:214 [▼
      0 => {#276 ▼
        +"name": "total_kills"
        +"value": 80323
      }
      1 => {#259 ▶}
      2 => {#272 ▶}
      3 => {#118 ▶}
{#651 ▼
  +"playerstats": {#278 ▼
    +"steamID": "76561198044179316"
    +"gameName": "ValveTestApp260"
    +"stats": array:214 [▶]
    +"achievements": array:167 [▼
      0 => {#484 ▼
        +"name": "WIN_BOMB_PLANT"
        +"achieved": 1
      }
      1 => {#485 ▶}
      2 => {#486 ▶}
      3 => {#487 ▶}