AwadGorg

AwadGorg

Member Since 1 Month Ago

Experience Points
1,210
Total
Experience

3,790 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
0
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 1
1,210 XP
Oct
19
1 day ago
Activity icon

Started a new Conversation Use Str_replace To Replace Words Within String

Hello, I want to use str_replace or any other function can do the same effect. to do this // let's say that I have this string

AD2460 is a browser-based Sci-Fi strategy MMORPG set in a persistent world. the game draws from real time Strategy titles and the developer's own influential 2001 web game, planetarion. AD2460 sees humans scattered all over the universe after the discovery of gates allowing travel through space with cultures, traditions, factions, and policies developing in their new locations.

and I have some world inside of it I want to change with other words.

$wordArray = array('ad2460', 'sci-fi', 'strategy');

I want to check if this word inside of the array is in the string if the words exist replace it with if sci-fi exists to replace it with sci-fi and so on how can I do so.

I've tried to use foreach like this

    echo str_replace($word, "<strong>" . $word . "</strong>", $string);
}

this just echo the string multiable times if 2 words from the array exists on the string will echo the string again and i don't want that and i also tried this

    $string = str_replace($word, "<strong>" . $word . "</strong>", $string);
}
echo $string;

this only replace the last element on the array this is the only one that works for me but it's too messy and this is the one am using right now

<?php
$Info = str_replace(strtolower($row['game_name']), 
'<strong class="text-dark text-capitalize">'.$row["game_name"].'</strong>', strtolower($reviewRow['gameOverview']));
$Info = str_replace(" mmorpg ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/mmorpg" rel="tag" class="text-info"> MMORPG </a></strong>', $Info);
$Info = str_replace(" anime ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/anime" rel="tag" class="text-info"> Anime </a></strong>', $Info);
$Info = str_replace(" action ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/action" rel="tag" class="text-info"> Action </a></strong>', $Info);
$Info = str_replace(" fantasy ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/fantasy" rel="tag" class="text-info"> Fantasy </a></strong>', $Info);
$Info = str_replace(" fps ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/fps" rel="tag" class="text-info"> FPS </a></strong>', $Info);
$Info = str_replace(" mobile ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/mobile-games/" rel="tag" class="text-info"> Mobile </a></strong>', $Info);
$Info = str_replace("mobile game", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/mobile-games/" rel="tag" class="text-info"> Mobile Game </a></strong>', $Info);
$Info = str_replace(" fps ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/fps" rel="tag" class="text-info"> TPS </a></strong>', $Info);
$Info = str_replace(" sci-fi ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/sci-fi" rel="tag" class="text-info"> Sci-Fi </a></strong>', $Info);
$Info = str_replace(" scf fi ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/scf-fi" rel="tag"> Sci-Fi </a></strong>', $Info);
$Info = str_replace(" simulation ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/simulation" rel="tag" class="text-info"> Simulation </a></strong>', $Info);
$Info = str_replace(" sport ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/sport" rel="tag" class="text-info"> Sport </a></strong>', $Info);
$Info = str_replace(" strategy ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/strategy" rel="tag" class="text-info"> Strategy </a></strong>', $Info);
$Info = str_replace(" text based ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/text-based" rel="tag" class="text-info"> Text-Based </a></strong>', $Info);
$Info = str_replace(" text-based ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/text-based" rel="tag" class="text-info"> Text-Based </a></strong>', $Info);
$Info = str_replace(" cross platform ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/mobile-games/" rel="tag" class="text-info"> Cross Platform </a></strong>', $Info);
$Info = str_replace(" cross-platform ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/mobile-games/" rel="tag" class="text-info"> Cross Platform </a></strong>', $Info);
$Info = str_replace(" mmo ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/mmorpg" rel="tag" class="text-info"> MMO </a></strong>', $Info);
$Info = str_replace(" browser game", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/" rel="tag" class="text-info"> Browser Game </a></strong>', $Info);
$Info = str_replace(" shooter ", 
'<strong class="text-info text-capitalize"><a href="'.BASE_URL.'/browser-games/fps" rel="tag" class="text-info"> Shooter </a></strong>', $Info);
$Info = str_replace(" features", 
'<strong class="text-dark h5 text-capitalize font-weight-bold"> Features </strong>', $Info);
$Info = str_replace(" feature ", 
'<strong class="text-dark text-capitalize font-weight-bold"> Feature </strong>', $Info);
$Info = str_replace(" multiplayer", 
'<strong class="text-dark text-capitalize font-weight-bold"> multiplayer </strong>', $Info);
$Info = str_replace(" main points ", 
'<strong class="text-dark h5 text-capitalize font-weight-bold"> Features </strong>', $Info);
$Info = str_replace(" free-to-play ", 
'<strong class="text-dark text-capitalize font-weight-bold"> Free-To-Play </strong>', $Info);
$Info = str_replace(" tactical ", 
'<strong class="text-dark text-capitalize font-weight-bold"> tactical </strong>', $Info);
$Info = str_replace(" character", 
'<strong class="text-dark text-capitalize font-weight-bold"> character </strong>', $Info);
$Info = str_replace(" event", 
'<strong class="text-dark text-capitalize font-weight-bold"> Event </strong>', $Info);
$Info = str_replace(" gear ", 
'<strong class="text-dark font-weight-bold"> gear</strong>', $Info);
echo $Info;
?>

can anyone give me a bitter way to do this

Activity icon

Started a new Conversation Using Image Intervention To Resize Images

Hello, Am using am intervention to resize my images this is the code

 $image->resize(208,130)->save(storage_path('app/public/'.$gameUploadFolder.'/'.$this->folderName.'/'. $this->fileNameToStore), 100);

it works nice and am using the 100 at the end to get the best quality possible from the image after resizing but it just doubled the image size without affecting the image quality the image stays the same when i removed the 100 from the end and decreased the image size too why is that.

Oct
13
1 week ago
Activity icon

Replied to Getting Call To A Member Function With() On String When Getting Data From Db

Oh I can't believe that I didn't notes that i made the ->with the inside of the view lol I spend the last 30 min searching what did i do wrong maybe cuz am so sleepy or something didn't notes thanks mate

Activity icon

Started a new Conversation Getting Call To A Member Function With() On String When Getting Data From Db

Hello, I have this basic eloquent DB select code but It shows me an error when i try to send this data to a view with both ->with or ->compact this is the code am using

public function show(Onlinegames $onlinegames, $g_page_link)
    {
        $onlinegame = Onlinegames::where('g_page_link',$g_page_link)->first();
        return view('online-games.online-game.show'->with('onlinegame', $onlinegame));
    }

when I use return $onlinegame to check if the query above get any result from the database I get a data but for some reason, the data got from the DB won't be bassed to the view this is the check code I used

public function show(Onlinegames $onlinegames, $g_page_link)
    {
        $onlinegame = Onlinegames::where('g_page_link',$g_page_link)->first();
        return $onlinegame;
        return view('online-games.online-game.show'->with('onlinegame', $onlinegame));
    }
Oct
12
1 week ago
Activity icon

Replied to OrderBy Average Using DB Class

Hello bro thanks for your reply I already know the logic using pure PHP but since am new to laravel I don't know to use OrderBy to get the raws from table1 based on the average rating on table2 that hold the ratings am changing my website from pure PHP to laravel and i already have this working on my website but it be pain in the *** for me to apply what I know how to do with PHP using laravel eloquent

Activity icon

Started a new Conversation OrderBy Average Using DB Class

Hello, I have this DB query

<?php 
namespace App\Traits;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
trait Top4GamesTrait{
    public function getTop4Games($db_tablename, $db_rating_tablename, $db_media_tablename){
    return $top_games = DB::table($db_tablename)->select($db_tablename.'.g_name', $db_tablename.'.g_page_link', $db_rating_tablename.'.rating', $db_media_tablename.'.g_main_img')->leftjoin($db_rating_tablename, $db_tablename.'.id', $db_rating_tablename.'.game_id')->leftjoin($db_media_tablename, $db_tablename.'.id', $db_media_tablename.'.g_id')->groupBy($db_tablename.'.id')->OrderByRaw('AVG('.$db_rating_tablename.'.rating)','DESC')->take(4)->get();
    }
}

I wnt to show the items based on the item average rating from the bigger to small right now am using this code abovce and it does not make any changes from the reqular query without the OrderBy I get the same result with this query aand requalr get query without the order by why is the orderBy not working and how can i fix this Oh that has been is very big issue for me now it's been like three days with this problem everytime i fix something something else come up

not if i used just OrderBy insted Of the orderByRaw i get an error. And thanks for help in advanced

Oct
10
1 week ago
Activity icon

Replied to DB Use Select To Get Avg And Then Using The OrderBy To Order The Items By The Avg From The Select

Hello Bro, I did what you said and it returned an error for me

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'AVG(browsergames_rating.rating)' in 'order clause' (SQL: select `browsergames`.*, `browsergames_rating`.`rating`, `browsergames_media`.* from `browsergames` left join `browsergames_rating` on `browsergames`.`id` = `browsergames_rating`.`game_id` left join `browsergames_media` on `browsergames`.`id` = `browsergames_media`.`g_id` group by `browsergames`.`id` order by `AVG(browsergames_rating`.`rating)` desc limit 4)

the code

$top_games = DB::table('browsergames')->select('browsergames.*', 'browsergames_rating.rating', 'browsergames_media.*')->leftjoin('browsergames_rating', 'browsergames.id', 'browsergames_rating.game_id')->leftjoin('browsergames_media', 'browsergames.id', 'browsergames_media.g_id')->groupBy('browsergames.id')->OrderBy('AVG(browsergames_rating.rating)','desc')->take(4)->get();
Activity icon

Started a new Conversation DB Use Select To Get Avg And Then Using The OrderBy To Order The Items By The Avg From The Select

Hello, I have this code

$top_games = DB::table('browsergames')->leftjoin('browsergames_rating', 'browsergames.id', 'browsergames_rating.game_id')->leftjoin('browsergames_media', 'browsergames.id', 'browsergames_media.g_id')->select('browsergames.*', 'AVG(browsergames_rating.rating) AS avgRating', 'browsergames_media.*')->orderBy('avgRating', 'desc')->groupBy('browsergames.id')->take(4)->get();

i want to get the average of the user rating and asign a nickname on it and then using the order by i want to order games based on the avgRating of the game desc right now am using the code above but it returns an error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'AVG(browsergames_rating.rating)' in 'field list' (SQL: select `browsergames`.*, `AVG(browsergames_rating`.`rating)` as `avgRating`, `browsergames_media`.* from `browsergames` left join `browsergames_rating` on `browsergames`.`id` = `browsergames_rating`.`game_id` left join `browsergames_media` on `browsergames`.`id` = `browsergames_media`.`g_id` group by `browsergames`.`id` limit 4)
Activity icon

Replied to Select And GroupBy Are Not Working

I just sit the database.php config MySQL to false and everything is working now I have another problem that I want to select avg('browsergames_rating') as avgRating and then I want to orderBy using the avgRating this is code am using but it return an error

$top_games = DB::table('browsergames')->leftjoin('browsergames_rating', 'browsergames.id', 'browsergames_rating.game_id')->leftjoin('browsergames_media', 'browsergames.id', 'browsergames_media.g_id')->select('browsergames.*', 'AVG(browsergames_rating.rating) AS avgRating', 'browsergames_media.*')->orderBy('avgRating', 'desc')->groupBy('browsergames.id')->take(4)->get();
Oct
09
1 week ago
Activity icon

Started a new Conversation Select And GroupBy Are Not Working

I don't know how to explain this so just let me show you I have this code

$top_games = Browsergames::join('browsergames_rating', 'browsergames.id', 'browsergames_rating.game_id')->select('browsergames.*')->orderBy('rating', 'DESC')->take(4)->get();

first is getting the data from the browser games table and join the browsergames_rating table to it the browsergames_rating table has many rows with the same game_id many users can rate the same game so now the code above is showing let's see if game one have 5 rating rows in the rating table and it will show the game one 5 times and i don't want that so i used the gropBy to group data using the browsergames table insted of the browsergames_rating but it returned an error this is the code

$top_games = Browsergames::join('browsergames_rating', 'browsergames.id', 'browsergames_rating.game_id')->select('browsergames.*')->orderBy('rating', 'DESC')->groupBy('browsergames.id')->take(4)->get();

and this is the error

SQLSTATE[42000]: Syntax error or access violation: 1055 'ovongames.browsergames.g_name' isn't in GROUP BY (SQL: select `browsergames`.* from `browsergames` inner join `browsergames_rating` on `browsergames`.`id` = `browsergames_rating`.`game_id` group by `browsergames`.`id` order by `rating` desc limit 4)

and this is the code am using in my pure php website

// get the games from the browsergames table
                $getGames  = "SELECT browsergames.game_name,browsergames.id,browsergames.game_tag,browsergames.game_link,browsergames.game_img_path,browsergames.mainImg,
                browsergames.reviewGameName,rating.game_id,rating.rating,
                AVG(rating.rating) AS avgRating FROM browsergames LEFT join rating ON
                browsergames.id = rating.game_id GROUP BY browsergames.id ORDER BY avgRating DESC LIMIT 4";

is there a way to do this with laravel without returning an error and thanks a lot.

Activity icon

Replied to Finding Rows In Database Table Using Laravel Eloquent

Yes am tottally new to frameworks I have tuns of tutorials am watching but i want to build me some application to keep what i already now about laravel and also thanks a lot for your help I removed the select from my query

$checkRatings = $ratingTable::where([['user_id', $userId], ['game_id', $gameId]])->first();

and changed the find to

$insertRating = $ratingTable::find($checkRatings->id);
Activity icon

Started a new Conversation Finding Rows In Database Table Using Laravel Eloquent

Hello, I Have this code

$checkRatings = $ratingTable::select('browsergames_rating.id')->where([['user_id', $userId], ['game_id', $gameId]])->first('id');

and also tried it with

$checkRatings = $ratingTable::select('browsergames_rating.id')->where([['user_id', $userId], ['game_id', $gameId]])->get('id');

I am using it to the first check if the user who is rating the item is rated it before or not and also I want to get the id from the table and both of these are done but when I try to use the id from the code to find the row in the database that the user is tried to rate and update there previews rating

$insertRating = $ratingTable::find($checkRatings);

and when I tried to echo out the $checkRatings var to see what's wrong it turned out that it shows the data retrieved from the database in this format

echo $checkRatings; die();

output

{"id":8}

expected output

5

so I can use the 5 and the five here is the id and find the row and update it part of the code I amusing

/**
    * function to insert ratings from registered users
    **/
    protected function userRating($gameId, $index, $expire, $ratingTable){
    // if the session is set and the user rating is already a member
    $userId = Auth::user()->id;
    $checkRatings = $ratingTable::select('browsergames_rating.id')->where([['user_id', $userId], ['game_id', $gameId]])->first('id');
    echo $checkRatings; die();
    if (!empty($checkRatings)) {
        $insertRating = $ratingTable::find($checkRatings);
        $insertRating->rating = $index;
        $insertRating->game_id = $gameId;
        $insertRating->user_id = $userId;
        $insertRating->save();
        echo "Thank you for rating this game " . $index . " Out Of 5";
    }else{
        $insertRating = new $ratingTable;
        $insertRating->rating = $index;
        $insertRating->user_id = $userId;
        $insertRating->game_id = $gameId;
        $insertRating->save();
        echo "Thank you for rating this game " . $index . " Out Of 5";
    }
    }

i tried to json_encode the $checkRatings but still return the another problem

Activity icon

Replied to Using Different Get Routes For The Same Page

the g_page_link comes from the URL /browser-game/tentlan

I need it to identify the game and then fetch the rating for this game

Activity icon

Started a new Conversation Using Different Get Routes For The Same Page

Hello, I want to make an ajax request to get data for the page am in but the thing is I still have a get route to show the page content these are the routes

Route::get('/browser-game/{g_page_link}','[email protected]');
Route::get('/browser-game/{g_page_link}','[email protected]');

and this is the js I am using

$(document).ready(function(){
        function loadRatings(){
            $.ajax({
                url: '{{ route('[email protected]') }}'
                method: 'get', 
                success: function(data){
                    $("#loadGameRating").html(data);
                }
            })
        }
    });
</script>

the second route override the first route does there anyway that i can use this 2 routes and thanks

Oct
08
1 week ago
Activity icon

Replied to Does There Any Website That Offer Tutorials On How To Do Star Rating System In Laravel

Yes i don't want ready to use classes i want to custom build my own rating system that is better for my needs

Activity icon

Started a new Conversation Does There Any Website That Offer Tutorials On How To Do Star Rating System In Laravel

Hello I want to build star rating system for my website and I've been searching on google on how to do so using ajax and laravel but couldn't find any can you please direct me if you know a website and thanks

Activity icon

Replied to How To Change Words On String If There Is Matching Word In The String To The Word In The Array

and also I have another problem on redirecting users if he inputs an incorrect input to the input field

// validate the game tags entered by the user
    public function validateGameTags($request){
    // allowed tags
    $tags = array('3d', '2d', 'action', 'anime', 'fantasy', 'fps', 'mmorpg', 'sci-fi', 'simulation', 'sports', 'strategy', 'text-based');
    // get the user entered tags
    $entered_tags = $request->g_tags;
    // explode the user entered tags to an array
    $explode_tags = explode(',', strtolower(rtrim($entered_tags)));
    // loop throw the tags
    foreach ($explode_tags as $explode_tag) {
    // check each tags to the array $tags above
    if (!in_array($explode_tag, $tags)) {
        return redirect('/admin/browsergames/')->with('error', 'Oops!!! Look like you entered an unknown Tag in the game tags field.');
    }
    }
    }

the code above check if the user entered correct or incorrect tags if they entered incorrect tags stop the code and return an error but the code processes not stoping it still goes on and complete the code process why is that happeing is there anything wrong with my code or my redirection

here is where am using the trait above

public function update(Request $request, $id)
    {
        // validate if the entered tags are valid
        $this->validateGameTags($request);
        $this->validateInputFields($request);
        $updateGame = Browsergames::find($id);
        $updateGame->g_name = $request->input('g_name');
        $updateGame->g_link = $request->input('g_link');
        $updateGame->g_features = $request->input('g_features');
        $updateGame->g_info = $request->input('g_info');
        $updateGame->g_tags = $request->input('g_tags');
        $updateGameMedia = BrowsergamesMedia::find($id);
        $updateGameMedia->g_video_overview = $request->input('g_video_overview');
        $updateGame->save();
        $updateGameMedia->save();
        return redirect('/admin/browsergames/edit/'.$id)->with('success', 'Game info been updated successfully');
    }

and note that it returns the error message but didn't stop the rest of the submiting process

Activity icon

Started a new Conversation How To Change Words On String If There Is Matching Word In The String To The Word In The Array

Hello, I want to get a string from the database table and check the string if it contains words that I already put inside of an array t this is the array of words I want to check

@php
    $game_tags = array('3d', '2d', 'action', 'anime', 'fantasy', 'fps', 'mmorpg', 'sci-fi', 'simulation', 'sports', 'strategy', 'text-based');
    @endphp

and this is the string right now am only checking if the game name exists on the string if so i changed the game name color what i want is to check if the game tags exist on the string if there exists I want to put the tag on a link to the tag page how can i do so

{!! str_replace($game_info->g_name, '<strong class="text-info">'.$game_info->g_name.'</strong>', $game_info->g_info) !!}
Activity icon

Replied to Help Selecting Data From The Database Using Laravel

what this suppose to mean

->leftjoin('users')
Activity icon

Replied to Help Setting Active Class To Bootstrap Carousel

these are the js files I am using

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
Activity icon

Started a new Conversation Help Setting Active Class To Bootstrap Carousel

Hello I have this image slider that gets the images from the database and I want to set the active class I've been able to set the active class to the first item but for some reason, the next and prev button is not working I can't go to the next image or the prev one this is the code am using

<!-- Slideshow container -->
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
    @php
    $decodeImg = json_decode($game_info->BrowsergamesMedia->g_high_img);
    @endphp
     <ol class="carousel-indicators">
    @for($i = 0; $i <= count($decodeImg); $i++)
     <li data-target="#carouselExampleIndicators" data-slide-to="{{ $i }}" class="{{ $i == 0 ? ' active' : '' }}"></li>
    @endfor
    </ol>
    @foreach($decodeImg AS  $key => $imgThumb)
    <div class="carousel-inner">
    <div class="carousel-item {{ $key == 0 ? ' active' : ''  }}">
      <img class="d-block w-100" src="{{ asset('storage/browsergames-images/'.$game_info->g_page_link.'/thumbnails/'.$imgThumb)  }}" alt="Second slide">
    </div>
  </div>
    @endforeach
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
<!-- the slideshow container ends here -->
Oct
07
1 week ago
Activity icon

Started a new Conversation Help Selecting Data From The Database Using Laravel

Hello, I have this gaming website and on the website, I have a form that enables users from reviewing the game and am allowing guests and members to review the games now am setting the reviewd_by to 0 if the one that reviewing the game is guest and if the one that reviewing the game is user then am setting the user id

public function show($g_page_link)
    {
        // get the game from the db  table using the link
        $game = Browsergames::where('g_page_link',$g_page_link)->get();
        // get random games from the browsergames table
        $randBrowsergames = Browsergames::inRandomOrder()->take(4)->get();
        // get the game images from the browsergames_media table
        $game_media = BrowsergamesMedia::has('Browsergames')->get();
        // get the average game rating
        $avg_game_rating = browsergamesRating::has('browsergames')->avg('rating');
        // get the number of rating
        $count_game_rating = browsergamesRating::has('browsergames')->count('rating');
        // get the users reviews for the game
        $game_reviews = Browsergames::join('browsergames_reviews','browsergames.id', 'browsergames_reviews.r_g_id')->join('users', 'browsergames_reviews.r_user_id', 'users.id')->orderBy('browsergames_reviews.created_at', 'DESC')->get();
        $game_data = array('game' => $game, 'game_media' => $game_media,
        'avg_game_rating' => $avg_game_rating, 'count_game_rating' => $count_game_rating, 'randBrowsergames' => $randBrowsergames, 'game_reviews' => $game_reviews);
        return view('browser-games.browser-game.index')->with($game_data);
    }

now by using the code above join it not getting the reviews that have 0 value that represent the guest how can i fix that and if the Question is not clear please till so i can improve it and thanks so much for the help.

Oct
03
2 weeks ago
Activity icon

Replied to Please Help Setting Relationships Using Eloquent

Well thanks very much, bro it works very well. thanks again

Oct
02
2 weeks ago
Activity icon

Started a new Conversation How To Prevent Guest From Keeping Inserting Data To The Database

Hello, I have a rating system and I want to give the guest the ability to rate stuff but I also want to let him/her to be able to rate only one time and can't rate more than once I can use cookie for this but the guest can delete the cookie and rate again does there any safier way to do that using PHP.

Activity icon

Started a new Conversation Please Help Setting Relationships Using Eloquent

Hello, am building this new website and I have three table browser games are the parent and browsergamesMedia is the first child and BrowsergamesRating is the second child what I want is to show the result from the Browsergames table and the BrowsergamesMedia table this is the code I am using to do so

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Browsergames extends Model
{
    protected $table = "browsergames";
    public function BrowsergamesMedia(){
        return $this->hasOne('App\BrowsergamesMedia', 'g_id');
    }
    public function browsergamesRating(){
        return $this->hasMany('App\browsergamesRating', 'game_id');
    }
}
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class BrowsergamesMedia extends Model
{
    protected $table = 'browsergames_media';
    public function Browsergames(){
        return $this->belongsTo('App\Browsergames', 'id');
    }
}
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class browsergamesRating extends Model
{
    protected $table = "browsergames_rating";
    public function Browsergames(){
        return $this->belongsTo('App\Browsergames', 'id');
    }
}

not that the games has one Media row in the browsergamesMedia table and hasMany rows in the rating table

public function index()
    {
        $games = Browsergames::orderBy('created_at', 'DESC')->paginate(16);
        /*
        * explode the game_main_img to get the name of the image without the ext and replace the old ext with the jpg ext to use as a fullback 
        */
        $data = array('games' => $games);
        return view('browser-games.index')->with($data);
    }

now this code is working very nice displing content on my view but what I want is to make another var that will display games based on the ratings they got from the BrowsergamesRatingtable and i think that can only be done in the controller but i don't know how to do so am new in laravel

Oct
01
2 weeks ago
Activity icon

Replied to Laravel Database Relationships Issues

my foreign key is working fine I guess the issue is with the

$games = Browsergames::all();

someone said to me I should use

$games = Browsergames::find(1);

instead of my code above and it fixed the problem but now am getting only one row from the database and i want all rows

Activity icon

Started a new Conversation Edit Return 404 Error Not Found View In Resource Route

Hello, I have this resource route

Route::resource('/admin/browsergames/','AdminBrowsergamesController');

it works fine on the creation and the index method but when I tried the edit and delete method it won't work i don't know why and when I changed the resource route to this

// this are the routes for the admin browser games control start here
Route::get('/admin/browsergames/', '[email protected]')->middleware('auth');
Route::get('/admin/browsergames/create', '[email protected]')->middleware('auth');
Route::post('/admin/browsergames/', '[email protected]')->middleware('auth');
Route::get('/admin/browsergames/{id}', '[email protected]')->middleware('auth');
Route::get('/admin/browsergames/edit/{id}', '[email protected]')->middleware('auth');
Route::post('/admin/browsergames/update/{id}', '[email protected]')->middleware('auth');
Route::delete('/admin/browsergames/destroy/{id}', '[email protected]')->middleware('auth');
// this are the routes for the admin browser games control ends here

the edit and the delete method worked fine but using this in every resource i have well make the web.php so messy does there any other way to make sure that this route work and be less messy and thanks

Activity icon

Started a new Conversation How To Set Active Class To Sidebarli Based On The Page Url Using Php

I have this sidebar

<ul class="list-unstyled components">
                <p class="text-warning">Manage Games</p>
                <hr>
                <li class="active">
                    <a href="#browserGamesDropDown" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle text-light">Browser Games</a>
                    <ul class="collapse list-unstyled" id="browserGamesDropDown">
                        <li>
                            <a href="/admin/browsergames/create" class="text-light">Add Game</a>
                        </li>
                        <li>
                            <a href="/admin/browsergames-reviews/" class="text-light">Users Reviews</a>
                        </li>
                        <li>
                            <a href="/admin/edit-browsergame" class="text-light">Edit Game</a>
                        </li>
                    </ul>
                </li>
                <li >
                    <a href="#mmoGamesDropdown" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle text-light">MMO Games</a>
                    <ul class="collapse list-unstyled" id="mmoGamesDropdown">
                        <li>
                            <a href="/admin/mmogames/create" class="text-light">Add Game</a>
                        </li>
                        <li>
                            <a href="/admin/mmogames-reviews/" class="text-light">Users Reviews</a>
                        </li>
                        <li>
                            <a href="/admin/edit-mmogame" class="text-light">Edit Game</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="#onlineGamesDropdown" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle text-light">Online Games</a>
                    <ul class="collapse list-unstyled" id="onlineGamesDropdown">
                        <li>
                            <a href="/admin/onlinegames/create" class="text-light">Add Game</a>
                        </li>
                        <li>
                            <a href="/admin/delete-onlinegame" class="text-light">Delete Game</a>
                        </li>
                        <li>
                            <a href="/admin/edit-onlinegame" class="text-light">Edit Game</a>
                        </li>
                    </ul>
                </li>
                <hr>
                <p class="text-warning">Users And Users Activate</p>
                <hr>
                <li>
                    <a href="#forumDropdown" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle text-light">Forum</a>
                    <ul class="collapse list-unstyled" id="forumDropdown">
                        <li>
                            <a href="/admin/topics" class="text-light">Topics</a>
                        </li>
                        <li>
                            <a href="/admin/replies" class="text-light">Replies</a>
                        </li>
                        <li>
                            <a href="/admin/flags" class="text-light">Flags</a>
                        </li>
                    </ul>
                </li>
                <li >
                    <a href="#UsersDropdown" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle text-light">Users</a>
                    <ul class="collapse list-unstyled" id="UsersDropdown">
                        <li>
                            <a href="/admin/user/pending" class="text-light">Pending</a>
                        </li>
                        <li>
                            <a href="/admin/user/active" class="text-light">Active</a>
                        </li>
                    </ul>
                </li>
                <li >
                    <a href="#commentsDropdown" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle text-light">Comments</a>
                    <ul class="collapse list-unstyled" id="commentsDropdown">
                        <li>
                            <a href="/admin/browsergames/comments" class="text-light">Browser games</a>
                        </li>
                        <li>
                            <a href="/admin/mmogames/comments" class="text-light">MMO Games</a>
                        </li>
                    </ul>
                </li>
            </ul>

and i want to set the acive class to the li link that is equal the link from the url bar in the browser how can i do something like that in static sidebar and thanks. note that this sidebar is included to my website admin pages

Activity icon

Replied to Laravel Database Relationships Issues

this is the code am using to get data from the browsergames table and show it in the admin page using the public index function

/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $games = Browsergames::all();
        return view('admin.index')->with('games', $games);
    }
Activity icon

Replied to Laravel Database Relationships Issues

i did what you said but still the same problem but when i changed the hasMany to hasOne everything worked fine why is that

Sep
30
2 weeks ago
Activity icon

Started a new Conversation How To Make Trait Usable In The Whole Website Pages

Hello, I have this trait

namespace App\Traits;
use App\BrowsergamesTags;
trait browsergamesTagsTrait{
    // get the games tags from the browsergames_tags table
    public function gameTags(){
        return $games_tags = BrowsergamesTags::orderBy('t_name', 'ASC')->get();
    }
}

this trait gets the games tags from my database tables and the tags are showed above in the navbar and the navbar is included to all website pages do there is a simple way to enable this trait for all pages beside going throw every page controller and use the trait inside of it. and thanks for the help.

Activity icon

Started a new Conversation Laravel Database Relationships Issues

Hello I have a browsergames that holds all off my games data and I have browsergames_media table that holds the images and the videos for the game and I set the foreign key g_id for it to equal the id from the browser games and I also have a browsergamesRating table to store the users rating for the game and I did the same here setting a foreign key that equals the id from the browsergames table now when I tried to set the relation between the two tables with the browsergames table I get an error that says Property name does not exist on this collection instance. I think this means that the relationship not working this is the code I am using

this is the browsergamesRating model

namespace App;

use Illuminate\Database\Eloquent\Model;

class browsergamesRating extends Model
{
    protected $table = "browsergames_rating";
    public function Browsergames(){
        return $this->belongsTo('App\Browsergames', 'game_id');
    }
}

and this is the browsergamesMedia Model

namespace App;

use Illuminate\Database\Eloquent\Model;

class BrowsergamesMedia extends Model
{
    protected $table = 'browsergames_media';
    public function Browsergames(){
        return $this->belongsTo('App\Browsergames', 'g_id');
    }
}

and this is the browsergames model

namespace App;

use Illuminate\Database\Eloquent\Model;

class Browsergames extends Model
{
    protected $table = "browsergames";
    public function BrowsergamesMedia(){
        return $this->hasMany('App\BrowsergamesMedia', 'id');
    }
    public function browsergamesRating(){
        return $this->hasMany('App\browsergamesRating', 'id');
    }
}

and this is the controller code that have something to do with the relationships

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use App\Adminbrowsergames;
use App\BrowsergamesMedia;
use App\Browsergames;
use App\browsergamesRating;
use App\Traits\UploadImagesTrait;
// import the Intervention Image Manager Class
use Intervention\Image\ImageManagerStatic as Image;

$games = Browsergames::all();
        return view('admin.index')->with('games', $games);

please help and i wish i expline the problem well please tell me if something is not clear and i want to get all of the row on the browsergames table

Activity icon

Replied to How Can I Customize The Pagination View In Laravel

thanks, mate that helps me alot

Activity icon

Started a new Conversation How Can I Customize The Pagination View In Laravel

hello laravel is using bootstrap to style the pagination and am not using bootstrap on my website so the design of pagination is not working how can I use my own CSS to customize the pagination and thanks

Sep
29
3 weeks ago
Activity icon

Replied to Error While Trying To Login

i did what you said and it worked fine I changed u_password to the password but now if I refreshed my page it automatically logs me out don't know why this is happening

Activity icon

Started a new Conversation Error While Trying To Login

am building my website login system and I get this error ErrorException Undefined index: password it takes me a while but I fixed this by making changes to the EloquentUserProvider class validateCredentials function

public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials['password'];

    return $this->hasher->check($plain, $user->getAuthPassword());
}

To

public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials['u_password'];

    return $this->hasher->check($plain, $user->getAuthPassword());
}

the u_password is the name of my input field. this fixed the problem but make a new problem for me now it says These Credentials Do Not Match Our Records.

and also i changed the public function username() { return 'username'; } to public function username() { return 'u_email'; } the u_email is the name of the email input on my form but still the same problem i can't login just getting this error These Credentials Do Not Match Our Records. no matter if i entered wrong email or wrong password just getting this error and i don't know what to do please help

Sep
05
1 month ago
Activity icon

Started a new Conversation Want Another Developer Opinon On My New Website

Hello guys I recently build up this website https://ovongames.com and i really want to know what you think about it your review will be great for me and thanks in advane.