AwadGorg

AwadGorg

Member Since 1 Year Ago

Experience Points
4,660
Total
Experience

340 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 your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • community-pillar Created with Sketch.

    Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 1
4,660 XP
Nov
17
2 weeks ago
Activity icon

Awarded Best Reply on Merge Two Collection Into One Variable

Well, I made some changes and it worked

$browsergames = $browsergames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $mmogames = $mmogames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $browsergames = new Collection($browsergames);
        $mmogames = new Collection($mmogames);
        $games = $browsergames->merge($mmogames);
        return view('layouts.search-data', compact('games'));

this code returned the data I've wanted

Activity icon

Replied to Merge Two Collection Into One Variable

Well, I made some changes and it worked

$browsergames = $browsergames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $mmogames = $mmogames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $browsergames = new Collection($browsergames);
        $mmogames = new Collection($mmogames);
        $games = $browsergames->merge($mmogames);
        return view('layouts.search-data', compact('games'));

this code returned the data I've wanted

Activity icon

Replied to Merge Two Collection Into One Variable

Here is what I did and make it more odd in my controller

$browsergames = $browsergames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $mmogames = $mmogames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $games = $mmogames->push($browsergames); 
        return $games;

I used push method and then return the data coming from the push method inside the controller and it returns the data

	
0	
g_name	"Perfect World"
g_page_link	"perfect-world"
category	"mmo-game"
1	
g_name	"Myth War 2 Online"
g_page_link	"myth-war-2-online"
category	"mmo-game"
2	
g_name	"GodsWar Online"
g_page_link	"godswar-online"
category	"mmo-game"
3	
g_name	"War Rock"
g_page_link	"war-rock"
category	"mmo-game"

then I removed the return $games and instead I've returned a view and passed the var $games to it

$browsergames = $browsergames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $mmogames = $mmogames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $games = $mmogames->push($browsergames); 
        return view('layouts.search-data', compact('games'));

now it should work when I use foreach in my blade file but it returns me an error that

Exception
Property [category] does not exist on this collection instance. (View: /home/awadgorg/projects/ovon/resources/views/layouts/search-data.blade.php) 

here is the blade code

@forelse ($games as $game) 
    <li class="list-group-item text-center">
        <a href="{{ url('/'.$game->category.'/'.$game->g_page_link) }}" 
            class="text-info font-weight-bold text-center">
            {{ $game->g_name }}
        </a>
    </li>
@empty
    hey
@endforelse

and I've tried using dd($games) in the blade and it returned the data

{{ dd($games) }}
@forelse ($games as $game) 
    <li class="list-group-item text-center">
        <a href="{{ url('/'.$game->category.'/'.$game->g_page_link) }}" 
            class="text-info font-weight-bold text-center">
            {{ $game->g_name }}
        </a>
    </li>
@empty
    hey
@endforelse

and it returned

Illuminate\Database\Eloquent\Collection {#1488 ▼
  #items: array:11 [▼
    0 => App\Models\Mmogames {#1469 ▶}
    1 => App\Models\Mmogames {#1484 ▶}
    2 => App\Models\Mmogames {#1485 ▶}
    3 => App\Models\Mmogames {#1508 ▶}
    4 => App\Models\Mmogames {#1510 ▶}
    5 => App\Models\Mmogames {#1486 ▶}
    6 => App\Models\Mmogames {#1493 ▶}
    7 => App\Models\Mmogames {#1495 ▶}
    8 => App\Models\Mmogames {#1478 ▶}
    9 => App\Models\Mmogames {#1482 ▶}
    10 => Illuminate\Database\Eloquent\Collection {#1471 ▼
      #items: array:10 [▼
        0 => App\Models\Browsergames {#1490 ▶}
        1 => App\Models\Browsergames {#1491 ▶}
        2 => App\Models\Browsergames {#1474 ▶}
        3 => App\Models\Browsergames {#1477 ▶}
        4 => App\Models\Browsergames {#1475 ▶}
        5 => App\Models\Browsergames {#1476 ▶}
        6 => App\Models\Browsergames {#1468 ▶}
        7 => App\Models\Browsergames {#1489 ▶}
        8 => App\Models\Browsergames {#1487 ▶}
        9 => App\Models\Browsergames {#1483 ▶}
      ]
    }
  ]
}
Activity icon

Replied to Merge Two Collection Into One Variable

As I've said in my question I've tried this way and it didn't work it only return one set of data and it should return 20

Nov
16
2 weeks ago
Activity icon

Replied to Merge Two Collection Into One Variable

Well, rookie wasn't needed but I've tried what you said and I got this error

ErrorException
array_merge(): Expected parameter 1 to be an array, object given 

that why i used method toArray

Activity icon

Replied to Merge Two Collection Into One Variable

Yes and it returned only one item

Illuminate\Database\Eloquent\Collection {#533 ▼
  #items: array:1 [▶]

it should return more

Activity icon

Started a new Conversation Merge Two Collection Into One Variable

Hello, I am getting data from 2 different rows in my database and I want to merge them into one variable so this one variable holds data from both db rows here is a code I've tried but didn't give me what I needed

$browsergames = $browsergames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $mmogames = $mmogames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $games = $browsergames->merge($mmogames);

for some reason the code above only returns one data set and am sure that each of the query above is returned with 10 data set each, and the second one I've tried

$browsergames = $browsergames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $mmogames = $mmogames::where('g_name', 'LIKE', '%'.$request->q.'%')->take(10)
        ->select(['g_name', 'g_page_link', 'category'])->get();
        $games = array_merge($browsergames->toArray(), $mmogames->toArray());

now the code above did return the data for me but in array inside an array like this

array:20 [▼
  0 => array:3 [▶]
  1 => array:3 [▶]
  2 => array:3 [▶]
  3 => array:3 [▶]
  4 => array:3 [▶]
  5 => array:3 [▶]
  6 => array:3 [▶]
  7 => array:3 [▶]
  8 => array:3 [▶]
  9 => array:3 [▶]
  10 => array:3 [▶]
  11 => array:3 [▶]
  12 => array:3 [▶]
  13 => array:3 [▶]
  14 => array:3 [▶]
  15 => array:3 [▶]
  16 => array:3 [▶]
  17 => array:3 [▶]
  18 => array:3 [▶]
  19 => array:3 [▶]
]

and I can't use the above data in my foreach i have to do 2 foreach for it to work i think and this is a live search system doing 2 foreach whenever the user type a letter will kill my website is there any way I can do this please and thanks a lot for the help

Nov
15
2 weeks ago
Activity icon

Replied to Lazy Load Iframe

Thanks mate this acutely helped me fix my issue here is the code I've used

@empty(!$game->media->g_video_overview)
        <div class="iframe_placeholder" onclick="myVid()" id="iframe_placeholder">
            <img data-src="{{ asset('storage/'.$imgFolder.'/'.$game->g_page_link.'/thumbnails/'.
        $game->decCodeImgThumb($game->media->g_high_img)[0])}}" alt="{{ $game->g_name }}" class="lazyload w-100 iframe_main_img"
         height="400">
         <img data-src="{{ asset('storage/icons/youtube.png') }}" alt="youtube icon"
          class="iframe_youtube_icon lazyload">
        </div>
        <div id="load-vid"></div>
        <script>
            function myVid() {
                iframe = `<iframe src="{{ $game->media->g_video_overview }}" frameborder="0" 
                    class="w-100" loading="lazy" height="400" autoplay allowfullscreen></iframe>`;
                document.getElementById("load-vid").innerHTML = iframe;
                document.getElementById('iframe_placeholder').classList.add('d-none');
            }
        </script>
    @endempty
Nov
14
2 weeks ago
Activity icon

Started a new Conversation Lazy Load Iframe

Hello, I have a video that I am embedding from YouTube and it kind of making my website slow, I notes that some sites have a photo with a play button when click on the iframe starts loading how can I do the same using JavaScript not jQuery and thanks a lot.

Nov
08
3 weeks ago
Activity icon

Replied to Image Upload Error When Uploadig .png Images But Upload .jpg Images

Hi, I do you mean I should remove

Storage::put('public/'.$imFolder.'/'.$game->g_page_link.'/thumbnails/'.$imgThumbNameToStore,
            fopen($imgThumb, 'r+'));

any way I removed the code above and still the same error

Intervention\Image\Exception\NotReadableException
Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files. 

the error only appear when I upload images with .png ext and covert these images to WebP but when I upload JPG images and covert to WebP everything works fine

Activity icon

Started a new Conversation Image Upload Error When Uploadig .png Images But Upload .jpg Images

Hello I have multi images upload system, it works fine when I upload images with ext of JPG but when I try to upload .png images it throw back an error

Intervention\Image\Exception\NotReadableException
Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files. 

and am sure that the images are in .png format and I get the same error when upload mix between .jpg and PNG images here is the code I am using, and I am using Traits to upload images

public function uploadImagesThumbs($request, $imFolder, $game){
        foreach ($request->file('g_high_img') as $imgThumb) {  
            $imgFullName = $imgThumb->getClientOriginalName();
            $explodeImgFullName = explode('.', $imgFullName);
            // get the image name without the ext
            $imgThumbName = current($explodeImgFullName);
            $imgThumbName = preg_replace('/[^a-zA-Z0-9]/', '-', strtolower($imgThumbName));
            //the file name that well be saved
            $imgThumbNameToStore = $imgThumbName.'_'.rand().'.webp';
            Storage::put('public/'.$imFolder.'/'.$game->g_page_link.'/thumbnails/'.$imgThumbNameToStore,
            fopen($imgThumb, 'r+'));
            $image = Image::make($imgThumb);
            $image->resize(700,400)->save(storage_path('app/public/'.$imFolder.'/'.
            $game->g_page_link.'/thumbnails/'. $imgThumbNameToStore));
            $image->resize(100,100)->save(storage_path('app/public/'.$imFolder.'/'.
            $game->g_page_link.'/thumbnails/sm_'. $imgThumbNameToStore));
            $this->imgThumbNameArray[] = $imgThumbNameToStore;
        } 
    }

And I am allowing the user to upload .png images

Activity icon

Replied to Set Custom Value To Html Input Type Date

No no no, i spent like an hour hour on this and it was an html error 🤒🤕😭😭😭😭😭

Activity icon

Started a new Conversation Set Custom Value To Html Input Type Date

Hello, I am making update form and I want to update a row in my db the update also except date I am trying to set the date value that already exists in my db row to the HTML input date but for some reason it's not working this is how I am trying to set the date

<input class="form-control" type="date" name="initial_release"
                            vlaue="{{  date('Y-m-d', strtotime($game->initial_release)) }}">

this function

{{  date('Y-m-d', strtotime($game->initial_release)) }}

return 2019-09-26

but HTML input is empty nothing shown in it and when I update the row it reset the date to null

Nov
05
4 weeks ago
Activity icon

Started a new Conversation Peform An Action On Form Submit

Hello, i have a checkbox and it return on if it checked and off if not checked and i want to give it value of if checked if not checked(off) and i don't want to use my controller to do it using if statement i remember back when i was learning laravel that there is a way to do this using the model but i forgot it and I've been looking for it on google for a while but nothing can you please help me with this, am trying to write a very clean code and thanks for the help

Nov
02
1 month ago
Activity icon

Replied to Laravel Components

You to 😁😁😁😁

Activity icon

Replied to Laravel Components

Thank's a lot, I've taking out the array in the return view and everything worked fine and now my code is cleaner thanks a lot for that and I've changed the button 2 div and am gonna avoid doing link inside of a button tag in the future thanks again for your answer it's so informative

Activity icon

Replied to Laravel Components

it's just a repo for my crud,

<?php 

namespace App\Repositories;
use App\Contracts\GamesContract;
use App\Models\Browsergames;
use App\Models\BrowsergamesTag;
use App\Models\Mmogames;
use App\Models\MmogamesTag;

class GamesRepository implements GamesContract {
    public function newGames($model)
    {
        
    }
    /**
     * @return array
     * combine 2 objects
     */
    public function mayLikeGames(){
        $may_like_game = Browsergames::select(['g_name', 'g_page_link', 'category'])
        ->inRandomOrder()->take(4)->get();
         return $may_like_game;
    }
    public function browsergamesTags(){
        return BrowsergamesTag::orderByDesc('t_name')->get();
    }
    public function MmogamesTags(){
        return MmogamesTag::orderByDesc('t_name')->get();
    }
}
Activity icon

Replied to Laravel Components

nothing still the same exception it's like didn't even enter the navbar.php I've tried dd('hello'); and it didn't print it and I've used the dd on the top of the render function but nothing happens

Activity icon

Replied to Laravel Components

I've tried what you suggested and got the same Exception

Activity icon

Started a new Conversation Laravel Components

Hello, i made a laravel component and i want to get data from my db and pass it to the component and i already did that but in the view throw error that the var that i already pass with the component does not exists here is my code

Navbar.php

<?php

namespace App\View\Components;

use Illuminate\View\Component;
use App\Repositories\GamesRepository;
class Navbar extends Component
{
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct(GamesRepository $games)
    {
        //
        $this->games = $games;
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|string
     */
    public function render()
    {
        $BrowsergamesTags = $this->games->BrowsergamesTags();
        return view('components.navbar', compact('BrowsergamesTags'));
    }
    public function BrowsergamesTags(){
        return $this->games->BrowsergamesTags();
    }
    public function MmogamesTags(){
        return $this->games->MmogamesTags();
    }
}

and the navbar.blade.php

<div class="dropdown main_header_con d-none d-md-inline-block">
            <button class="dropbtn">
                <a href="/browser-games" class="text-dec-none h-text-info">
                    <b>BROWSER GAMES</b> </a><i class="arrow down mt-3"></i>
            </button>
            <div class="dropdown-content">
                @foreach ($BrowsergamesTags as $browsergames_tag)
                <a href="{{ $browsergames_tag->t_link }}">
                    {{ $browsergames_tag->t_name }}
                </a>
                @endforeach
            </div>
        </div>

the error am getting

ErrorException
Undefined variable: BrowsergamesTags (View: /home/awadgorg/projects/ovon/resources/views/components/navbar.blade.php) 

I've tried these method two

 public function render()
    {
        return view('components.navbar', $this->BrowsergamesTags());
    }
    public function BrowsergamesTags(){
        return $this->games->BrowsergamesTags();
    }
    public function MmogamesTags(){
        return $this->games->MmogamesTags();
    }

still not working throw the same error

how am calling the component

<x-navbar />
Oct
31
1 month ago
Activity icon

Started a new Conversation Vuejs Laravel Pagination

Hello, am building this app to learn how to work with NUXTJS and am kind of stuck on how can i make pagination using nuxtjs(vuejs) with laravel i already made an api with laravel that return data using paginate, here is the code am using right now and it's not working,

<template>
  <div v-if="browsergames_list.last_page > 1">
    <ul class="pagination">
      <li
        class="page-item font-weight-bold ml-2"
        v-for="(link, index) in browsergames_list.links"
        :key="index"
        aria-current="page"
        :title="'Page ' + link.label"
      >
        <span
          class="page-link active"
          aria-disabled="true"
          v-if="link.label == browsergames_list.current_page"
        >
          {{ browsergames_list.current_page }}
        </span>
        <span
          class="page-link disabled"
          aria-disabled="true"
          v-else-if="link.url == null && link.label == '&laquo; Previous'"
        >
          &lsaquo;
        </span>
        <span
          class="page-link disabled"
          aria-disabled="true"
          v-else-if="link.label == 'Next &raquo;'"
        >
          <nuxt-link :to="'link.next_page_url'" class="text-dark">
            &rsaquo;
          </nuxt-link>
        </span>
        <span class="page-link" v-on:click="updateGames(link.label)"
        v-else>
          <nuxt-link :to="'?page='+link.label" class="text-dark"
            >
            {{ link.label }}
          </nuxt-link>
        </span>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: ['browsergames_list'],
  methods: {
      updateGames(page){
        Promise.all([
          this.$store.dispatch('browsergames/browsergamesListPagination', page)
        ])
      }
  }
}
</script>

the above is the pagination component, I have method updateGames that should be triggered when clicked on a link, and it should dispatch an action browsergamesListPagination and here is the vuex code

export default {
    state: () => ({
        browsergames_list: []
    }),
    mutations: {
        GET_GAMES(state, browsergames){
            state.browsergames_list = browsergames;
        }
    },
    actions: {
        async browsergamesList ({commit}){
            await this.$axios.get('/api/browsergames-list').then((res) => {
                commit('GET_GAMES', res.data);
            });
        },
        async browsergamesListPagination ({commit}, page){
            await this.$axios.get('/api/browsergames-list?page='+page
            ).then((res) => {
                commit('GET_GAMES', res.data);
            });
        }
}
}

the code above return this error for me

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at ‘http://localhost:8000/api/browsergames-list?page=2’. (Reason: Credential is not supported if the CORS header ‘Access-Control-Allow-Origin’ is ‘*’).

i want to know am i using the right way to do pagination. and why am i getting the error above and thanks a lot for the help

Oct
30
1 month ago
Activity icon

Replied to How To Use Methods Globally In NUXTJS(vue)

Hello, how can I pass the data to the gameGenre function using the first method here is the way am using and it's not working

<span
		<span
                class="float-right h5 games_container_row_info_con_title_header_gener"
              >
                {{ genre(latest_browsergame.g_tags) }}
              </span>
import { gameGenre } from '../../store/helpers.js';
export default {
  data(){
    return {
     genre: gameGenre(genre)
    }
  }
}

with the method am using above it says that the


ReferenceError
genre is not defined

Activity icon

Started a new Conversation How To Use Methods Globally In NUXTJS(vue)

Hello, I have this method that am using a it in my website and i want to be able to use it globally instead of writing it in any component

gameGenre(genre) {
      genre = genre.split(',')
      if (genre.includes('mmorpg') == true) {
        genre = 'MMORPG'
      } else if (genre.includes('strategy') == true) {
        genre = 'STRATEGY'
      } else if (genre.includes('action') == true) {
        genre = 'ACTION'
      } else if (genre.includes('fps') == true) {
        genre = 'SHOOTER'
      } else if (genre.includes('survival') == true) {
        genre = 'SURVIVAL'
      } else if (genre.includes('sports') == true) {
        genre = 'SPORTS'
      } else if (genre.includes('fighting') == true) {
        genre = 'FIGHTING'
      } else if (genre.includes('text-based') == true) {
        genre = 'TEXT BASED'
      } else {
        genre = 'Undefined Yet'
      }
      return genre
    }
```
the method above accept string value and then i covert the string to an array using split(,) and then check if any of the words i want is in the array and so on, how can i use this globally and thanks a lot for the help.
Oct
26
1 month ago
Activity icon

Replied to Vuex Dispatch 2 Actions

thanks a lot mate this fixed my problem now can you please just tell me sending http request to get data from my db throw api that will slow down the website on the first load right?

Oct
25
1 month ago
Activity icon

Started a new Conversation Vuex Dispatch 2 Actions

Hello, am learning nuxt js to build server driven apps and so on, am in a point that i want to dispatch 2 actions to get data from 2 different sources, I don't know how to explain this the right way since am still learning here is my code hope it will make better to understand

async fetch({ store }) {
return await store.dispatch('featuredOnlinegames', 'latestNews')
},
computed: {
...mapState(['featured_onlinegames', 'latest_news'])
},

i want to dispatch an actions featuredOnlinegames and latestNews now with the way am using above it's not working i only get data from the featuredOnlinegames action but the latestNews return empty array

now here is my vuex code

  export default {
    state: () => ({
      featured_onlinegames: [],
      latest_news: []
    }),
    mutations: {
      GET_FEATURED_ONLINEGAMES(state, featured_onlinegames){
          state.featured_onlinegames = featured_onlinegames;
      },
      GET_LATEST_NEWS(state, latest_news){
        state.latest_news = latest_news;
      }
    },
    actions: {
      async featuredOnlinegames({commit}) {
        await this.$axios.get('/api/featured-onlinegames').then(res => {
          commit('GET_FEATURED_ONLINEGAMES', res.data)
        })
      },
      async latestNews({commit}) {
        await this.$axios.get('/api/latest-news').then(res => {
          commit('GET_LATEST_NEWS', res.data);
        });
      }
    }
  }

and one more question i don't know but when i started learning nuxt because everybody keep saying that nuxt is SEO friendly but with all these http request i have to send to get data from my db don't that kills the website and just add more weight to it and slow it down? right now am building a website and am still working on the top section of the website and i already have 4 http request to get data from db using axios not mentioning the images and the css and more, I have some dought that vue js nuxt is indeed SEO friendly will be more than glad if you helped clarify this for me and thanks a lot

Activity icon

Replied to Format Datetime In Vue

thanks a lot mate I've decided to use vanila js, just a simple Question what the difference what it make to use external library, cuz i think it just http request for nothing, this is the code I've used

return date.toLocaleDateString('en-US', {
	  day: '2-digit', // "01"
	  month: 'short', // "Jun"
	  year: 'numeric' // "2019"
	});

gave me the result I've wanted thanks again for your help

Activity icon

Started a new Conversation Format Datetime In Vue

Hello, I have date format 2019-11-07T18:25:55.000000Z and i want to format it in a user friendly way using vue js

this is the code am using to get the date from db and display it in my template

<template>
<section class="featured-online-games container mt-4" id="featured-online-games">
	<div class="row mt-4 w-100">
		<h2 class="text-uppercase col-12 h5 font-weight-bold">
		Featured Free To Play Online Games
		</h2>
		<div class="col-xl-3 col-md-4 col-10 m-center mb-3 mb-md-0"
			v-for="(featured_onlinegame, index) in featured_onlinegames" :key="index">
			<div class="card grow shadow">
				<div class="img_wrapper">
					<img :src="'featured-onlinegames-images/'+
					featured_onlinegame.g_play_link+'/squire-'+featured_onlinegame.g_image"
					alt=""
					class="card-img-top">
				</div>
				<div class="card-body insert-before">
					<time class="badge badge-ftg mt-1 float-right p-1">
					{{ featured_onlinegame.created_at  }}
				</time>
				</div>
			</div>
		</div>
	</div>
</section>
</template>
<script>
import { mapState } from 'vuex'
export default {
	
async fetch({ store }) {
return await store.dispatch('featuredOnlinegames')
},
computed: {
...mapState(['featured_onlinegames']),
},
}
</script>
Oct
20
1 month ago
Activity icon

Started a new Conversation What Is The Best Way To Use Nuxt Js And Laravel

Hello, I want to use Nuxt js as my front-end and Laravel as an API so I've created laravel project and inside of the public function created the nuxt project and run npm run dev insde of the public and everything works fine and run php artisan serve at the root of project to handle API with laravel, the problem is the nuxt fetch method and asyncData are not working for some reason am I doing anything wrong. I want to make universal web app

Oct
19
1 month ago
Activity icon

Replied to Get Request With Axios Is Not Working

Well i just used the same code but this time inside of a method insted of the fetch and the code run fine the problem is with the fetch but i need to use to to preload my data and i tried the asyncData and it also didn't work, i just wanna know why fetch and asyncData not working

Activity icon

Started a new Conversation Get Request With Axios Is Not Working

Hello, am using NUXT Js as my front end and laravel as my backend to handle api's i tried sending an api with axios as a test to see if everything is working fine but nothing worked so I've checked the console to see if vue throw any error and i found no errors so i checked the network panel to see if axios sent the get request, there were no request been sent it like axios didn't even work and i already installed it, and am using it in my nuxt config file

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
  ]

here is how am fetching data from the api

fetch({$axios, store}){
        return $axios.get('http://127.0.0.1:8000/api/app-header-trending-games').then(res => {
            console.log(res);
            store.commit('getGames', res);
        })
    }

like you see above am console log the response but nothing in the console

and here is my vuex store

export default {
    state: () => ({
        games: []
    }),
    mutations: {
        getGames(state, games){
            state.games = games;
        }
    }
}

here is the laravel controller

public function appHeaderTrendingGames(){
        return ['status' => 'true'];
    }

and the laravel api route

Route::get('/app-header-trending-games', [App\Http\Controllers\BaseController::class, 'appHeaderTrendingGames']);

note that when i type the api url in the browser address bar it works fine

Oct
11
1 month ago
Activity icon

Started a new Conversation Uncaught TypeError In Vue Js App

Hello, am learning vuex and am kind of get stuck on some error and i couldn't solve it if you could help me please and thanks,

here is the error am getting

Uncaught TypeError: vue__WEBPACK_IMPORTED_MODULE_0__.default is undefined

and here is my main.js file

import Vue from 'vue'
import App from './App.vue'
import {store} from './store/store'

new Vue({
    el: '#app',
    render: h => h(App),
    store: store
    
})

and here is my store.js file which am importing in my main.js

import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

export const store = new Vuex.Store({
    state: {
        products: [
            {name: 'Banana Skin', price: 20},
            {name: 'Shiny Star', price: 40},
            {name: 'Green Shells', price: 60},
            {name: 'Red Shells', price: 80}
          ]
    }
});

and this is my App.vue file

<template>
    <div>
      <product-list-one></product-list-one>
      <product-list-two></product-list-two>
    </div>
</template>

<script>
import productListOne from './components/product-list-one.vue'
import productListTwo from './components/product-list-two.vue'
export default {
  name: 'App',
  data(){
    return {
      
    }
  },
  components: {
    'product-list-one':  productListOne,
    'product-list-two':  productListTwo
  }
}
</script>

<style>

</style>

and the product-list-one.vue which am importing at the top

<template>
  <div>
      <h2>
          Product List Two
      </h2>
      <ul>
          <li v-for="(product, index) in products" :key='index'>
              <span class="name">
                  {{ product.name }}
              </span>
              <span class="price">
                  ${{ product.price }}
              </span>
          </li>
      </ul>
  </div>
</template>

<script>
export default {
    computed: {
        products(){
            return this.$store.state.products
        }
    }
}
</script>

<style>

</style>
Oct
05
1 month ago
Activity icon

Replied to Pages Return 404 And All The Routes Are Correct But Still Page Return 404



# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

it was like this and i took .htacess file from one of my other projects and it worked fine pages are working now thanks a lot the new .htaccess looks like

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Activity icon

Started a new Conversation Pages Return 404 And All The Routes Are Correct But Still Page Return 404

Hello, I've uploaded my website to serve but for some reason it return 404 for all the pages except the homepage that does get called but every other page return 404 this is my route file

<?php
use App\Type;
use App\Field;
use App\Package;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'Site\[email protected]')->name('homepage');
Route::get('/change-lang/{val}', 'Site\[email protected]');
Route::get('/product/{id}', 'Site\[email protected]');
Route::get('/product-search', 'Site\[email protected]')->name('products.search-result');
Route::get('/products', 'Site\[email protected]');
Route::get('/product/rating/{id}', 'Site\[email protected]');
Route::get('/product/insert-rating/{id}', 'Site\[email protected]');
Route::get('/discount/{id}', 'Site\[email protected]');
Route::get('/discounts', 'Site\[email protected]');
Route::get('/category/{type}', 'Site\[email protected]');
Route::get('/login', 'Site\[email protected]')->name('login');
Route::post('/login', 'Site\[email protected]')->name('loginUser');
Route::get('/register', 'Site\[email protected]')->name('register');
Route::post('/register', 'Site\[email protected]')->name('registerUser');
Route::get('/user-profile', 'Site\[email protected]')->name('userProfile');
Route::post('/add-favorite/{product_id}', 'Site\[email protected]')->name('addToFav');
Route::post('/remove-favorite/{product_id}', 'Site\[email protected]')->name('removeFromFav');
Route::post('/registerUserLastStep', 'Site\[email protected]')->name('registerUserLastStep');
Route::get('/ajax/register-new-user-last-step', 'Site\[email protected]');
Route::get('/logout', 'Site\[email protected]');
Route::get('manege_types',function(){
    return view('vendor.multiauth.admin.pages.type');
})->name('types');

Route::get('manege_meat',function(){
    return view('vendor.multiauth.admin.pages.meats');
})->name('meats'); 

Route::get('manege_cattle_origin',function(){
    return view('vendor.multiauth.admin.pages.cattle_origin');
})->name('origin');

Route::get('manege_meat_shape',function(){
    return view('vendor.multiauth.admin.pages.meat_shape');
})->name('meat_shape');

Route::get('manege_meate_aera',function(){
    return view('vendor.multiauth.admin.pages.meate_area');
})->name('meat_aera');

Route::post('/add-to-cart', 'Site\[email protected]');
Route::get('/cart', 'Site\[email protected]')->name('checkout.cart');
Route::get('/cart/item/{id}/remove', 'Site\[email protected]')->name('checkout.cart.remove');
Route::get('/cart/clear', 'Site\[email protected]')->name('checkout.cart.clear');
Route::group(['middleware' => ['auth']], function () {
    Route::get('/checkout', 'Site\[email protected]')->name('checkout.index');
    Route::post('/checkout/save-latlng', 'Site\[email protected]')->name('checkout.saveLatLng');
    Route::post('/checkout/order', 'Site\[email protected]')->name('checkout.place.order');
    Route::get('/checkout/payment/complete', 'Site\[email protected]')->name('checkout.payment.complete');
    Route::get('/account/orders', 'Site\[email protected]rders')->name('account.orders');
});


Route::get('manege_discounts',function(){
    return view('vendor.multiauth.admin.pages.discounts');
})->name('discounts');

Route::get('manege_orders',function(){
    return view('vendor.multiauth.admin.pages.orders');
})->name('orders');


Route::get('manege_users',function(){
    return view('vendor.multiauth.admin.pages.users');
})->name('users');


and this is the 404 error message


Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

note the pages works fine at my localhost

Sep
27
2 months ago
Activity icon

Started a new Conversation Paypal Payment VALIDATION_ERROR Item Amount Must Add Up To Specified Amount Subtotal

hello, am building a store system using laravel and am stuck at the payment process am using paypal as my payment getway

this is the error am getting

400{"name":"VALIDATION_ERROR","details":[{"field":"transactions[0]","issue":"Item amount must add up to specified amount subtotal (or total if amount details not specified)"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"2a57264abb40a"}

this is my code

<?php

namespace App\Services;

use PayPal\Api\Payer;
use PayPal\Api\Item;
use Mockery\Exception;
use PayPal\Api\Amount;
use PayPal\Api\Payment;
use PayPal\Api\Details;
use PayPal\Api\ItemList;
use PayPal\Rest\ApiContext;
use PayPal\Api\Transaction;
use PayPal\Api\RedirectUrls;
use PayPal\Api\PaymentExecution;
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Exception\PayPalConnectionException;

class PayPalService
{
    protected $payPal;

    public function __construct()
    {

        $this->payPal = new ApiContext(
            new OAuthTokenCredential(
                'user key',
                'secret key'
            )
        );

    }
// $order is coming from the parent method and holds all the order info
    public function processPayment($order)
    {
        // Add shipping amount if you want to charge for shipping
        $shipping = sprintf('%0.2f', 0);
        // Add any tax amount if you want to apply any tax rule
        $tax = sprintf('%0.2f', 0);

        // Create a new instance of Payer class
        $payer = new Payer();
        $payer->setPaymentMethod("paypal");

        // Adding items to the list
        $items = array();
	// orderMeats get the items of the order
        foreach ($order->ordersMeats as $item)
        {
            $orderItems[$item->id] = new Item();
            $orderItems[$item->id]->setName($item->meat->ar_name)
                ->setCurrency('SAR')
                ->setQuantity($item->quantity)
                ->setPrice(sprintf('%0.2f', $item->price));

            array_push($items, $orderItems[$item->id]);
        }

        $itemList = new ItemList();
        $itemList->setItems($items);

        // Setting Shipping Details
        $details = new Details();
        $details->setShipping($shipping)
                ->setTax($tax)
                ->setSubtotal(sprintf('%0.2f', 0));

        // Create chargeable amount
        $amount = new Amount();
        $amount->setCurrency('SAR')
        /*
          ** $order holding all the orders 
          ** orderMeats is  the items inside the order
          ** get the sum of the price and set it as total
          **/
                ->setTotal(sprintf('%0.2f', $order->ordersMeats->sum('price')))
                ->setDetails($details);

        // Creating a transaction
        $transaction = new Transaction();
        $transaction->setAmount($amount)
                ->setItemList($itemList)
                ->setDescription($order->user->ar_name)
                ->setInvoiceNumber($order->id);

        // Setting up redirection urls
        $redirectUrls = new RedirectUrls();
        $redirectUrls->setReturnUrl(route('checkout.payment.complete'))
                     ->setCancelUrl(route('checkout.index'));

        // Creating payment instance
        $payment = new Payment();
        $payment->setIntent("sale")
                ->setPayer($payer)
                ->setRedirectUrls($redirectUrls)
                ->setTransactions(array($transaction));

        try {

            $payment->create($this->payPal);

        } catch (PayPalConnectionException $exception) {
            echo $exception->getCode(); // Prints the Error Code
            echo $exception->getData(); // Prints the detailed error message
            exit(1);
        } catch (Exception $e) {
            echo $e->getMessage();
            exit(1);
        }

        $approvalUrl = $payment->getApprovalLink();

        header("Location: {$approvalUrl}");
        exit;
    }

    public function completePayment($paymentId, $payerId)
    {
        $payment = Payment::get($paymentId, $this->payPal);
        $execute = new PaymentExecution();
        $execute->setPayerId($payerId);

        try {
            $result = $payment->execute($execute, $this->payPal);
        } catch (PayPalConnectionException $exception) {
            $data = json_decode($exception->getData());
            $_SESSION['message'] = 'Error, '. $data->message;
            // implement your own logic here to show errors from paypal
            exit;
        }

        if ($result->state === 'approved') {
            $transactions = $result->getTransactions();
            $transaction = $transactions[0];
            $invoiceId = $transaction->invoice_number;

            $relatedResources = $transactions[0]->getRelatedResources();
            $sale = $relatedResources[0]->getSale();
            $saleId = $sale->getId();

            $transactionData = ['salesId' => $saleId, 'invoiceId' => $invoiceId];

            return $transactionData;
        } else {
            echo "<h3>".$result->state."</h3>";
            var_dump($result);
            exit(1);
        }
    }
}
Sep
23
2 months ago
Activity icon

Replied to How Can I Print The Session Key And Value In The Screen

am making filter system with multi select or check box the user can check box1 and search with it and the the user check box2 now it should search with box 1 and box2

the way I've decided to make it is when the user clicks on box1 it send get request with ajax that holds the row name that the user want to search in and the id (value) and use the selector and the id to search in the db table and return result to the user, then when the user check box2 it also save the selector and the id of box2 in a session, I want to use the session key in this case its the table row and the session value the id, to search for both box1 and box2, here is part of my code hope it will make it more clear

$(document).ready(function(){
    $(".genral").click(function(){
        
        $("#overlay").fadeIn(300); 
        var elmId = $(this).attr("id");
            var livesearchVal = $("#livesearch").val();
            var types = $(this).attr("data-type");
            var selector = $(this).attr("data-uniqe");
        console.log(url + 'hey');
        $.ajax({
            
            type: 'GET',
            url: "/ajax/genaral_specializations2.php?id="+elmId+'&term='+livesearchVal+'&types='+types+'&selector='+selector,
            success: function(data){
               $("#paginate_books").html(data);
               $("#overlay").fadeOut(300); 
            }
        });
    });
});

var elmid = the value of the checkbox, var term = it's the search term that user entered in the input text (not important) var types = (not important) var selector = the table row name for example (table cast row name),

below is part of the controller controller

        $gen_spci_no = $_GET['id'];
        $table_uniqe = $_GET['selector'];
        session()->put($table_uniqe, $gen_spci_no);
        $input = collect($filter_sessions)->filter(function($value) {
            return null !== $value;
})->toArray();

like you see above I put the new session box2 alongside box1 I already know all the session names so am gonna loop throw them and get the once that already been set and assign them to the $input array this array should hold the session key and name like this

$input = array($sessionkey => $sessionval);
Sep
22
2 months ago
Activity icon

Started a new Conversation How Can I Print The Session Key And Value In The Screen

Hello, I've set a session key and value and then print to the screen session()->get(keyname); and this only return to me the keyname value and i want both to be returned cuz both of them are dynamic and am using them both to make another action does there anyway that i can get the session key and value,

what i want is to use them in where clause to get data from database

Sep
19
2 months ago
Activity icon

Replied to Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No Such File Or Directory

Sounds interesting, you mean going through every file to see what really caused the problem. Will do and let you know will be fun 🤗

Activity icon

Replied to Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No Such File Or Directory

Nope i didn't setup any models or migration i used DB to retrieve data from database in the new project and tried to copy database.php to the old one and also didn't work hill i even replaced the .env file to but also didn't work, so I've decided to move my files to the new project

Activity icon

Replied to Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No Such File Or Directory

I've download a fresh laravel app and used one of the controllers at the one that didn't work the same controller and it worked fine?

Activity icon

Replied to Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No Such File Or Directory

no there only cache folder and app.php file

everthing looks fine to me to the but nothing works I've had this problem since yesterday and I've been googling yet since then didn't find anything to help me fix the issue.

am using xampp running it through sudo /opt/lampp/lampp start and before running this code i run sudod /etc/init.p/apache2 stop to stop the apache2 to and then doing lampp start and it give me success mysql server opended and apache opend and tried to open phpmyadmin it opened fine and when i route to a file that doesn't get data from the db also works fine the db name in .env file is correct checked that like million time, am out of ideas

Activity icon

Replied to Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No Such File Or Directory

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=ovongames
DB_USERNAME=root
DB_PASSWORD=
Activity icon

Replied to Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No Such File Or Directory

did so and cleared the cache till the same problem

Activity icon

Replied to Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No Such File Or Directory

<?php

use Illuminate\Support\Str;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

    'default' => env('DB_CONNECTION', 'mysql'),

    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */

    'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'url' => env('DATABASE_URL'),
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
        ],

        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => false,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

        'pgsql' => [
            'driver' => 'pgsql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer body of commands than a typical key-value system
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [

        'client' => env('REDIS_CLIENT', 'phpredis'),

        'options' => [
            'cluster' => env('REDIS_CLUSTER', 'redis'),
            'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
        ],

        'default' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => env('REDIS_DB', 0),
        ],

        'cache' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => env('REDIS_CACHE_DB', 1),
        ],

    ],

];

Activity icon

Started a new Conversation Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No Such File Or Directory

Hello, am having this error

Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] No such file or directory

evertime i try to run my project I recently moved from windows to linux everything was working fine on my windows machine but now it shows the error above

things I've tried to do

run composer update | didn't solve the problem
run composer require doctrine/dbal | also didn't work
run apt install php-mysql | also didn't work
and run php -m  | and it listed pdo 

am running php v 7.4.3

Aug
09
3 months ago
Activity icon

Started a new Conversation Is Currently Unable To Handle This Request. On Form Post Submit

Hello, I have this login system that works with no issues on my localhost but when uploaded to the server it returns an error collage-clinic.epizy.com is currently unable to handle this request. could it be cuz of hosting cuz am using infinityfree anyway that's the code

<?php
/*
 * Tutorial: PHP Login Registration system
 *
 * Page index.php
 * */

// Start Session
session_start();
include '../db.php';
// Application library ( with DemoLib class )
require __DIR__ . '/../functions/register.php';
$app = new DemoLib();

$login_error_message = '';
$register_error_message = '';

// check Login request
if (!empty($_POST['btnLogin'])) {

    $log_email = trim($_POST['log_email']);
    $log_password = trim($_POST['log_password']);

    if ($log_email == "") {
        $login_error_message = 'البريد الالكتروني ضروري';
    } else if ($log_password == "") {
        $login_error_message = 'كلمة السر ضرورية';
    } else {
      $app->init();
        $user_id = $app->Login($log_email, $log_password, 'students'); // check user login
        die($user_id);
        if($user_id > 0)
        {
            $_SESSION['id'] = $user_id; // Set Session
            header("Location: ../profile/user.php"); // Redirect user to the profile.php
        }
        else
        {
            $login_error_message = 'Invalid login details!';
        }
    }
}

and this

public function Login($email ,$password, $table)
    {
        try {
            die('dxvm,d');
            $db = DB();
            if ($table == 'students') {
              $role = 1;
              die($db);
              $query = $db->prepare("SELECT id FROM users WHERE
                email=:email AND password=:password AND role = :role");
            }elseif ($table == 'doctors') {
              $role = 2;
              $query = $db->prepare("SELECT id FROM users WHERE
                email=:email AND password=:password AND role = :role");
            }

            $query->bindParam(":email", $email);
            $query->bindParam(":role", $role, PDO::PARAM_INT);
            $enc_password = hash('sha256', $password);
            $query->bindParam(":password", $enc_password);

            $query->execute();
            if ($query->rowCount() > 0) {
                $result = $query->fetch(PDO::FETCH_OBJ);
                return $result->id;
            } else {
                return false;
            }
        } catch (PDOException $e) {
            exit($e->getMessage());
        }
    }
Aug
08
3 months ago
Activity icon

Started a new Conversation How To Code Date Time Booking System In Pure Php

Hello, I started to build a booking system just for the purpose of learning and all of the tutorials that I found online only shows you how to make one using only dates booking using date only there is no time like I want to book for an appointment at Sunday 9 pm not just Sunday how can I do that, and thanks

Aug
07
3 months ago
Activity icon

Started a new Conversation Problem With Booking System

Hello, I am creating a booking system and I get stuck on this issue when the user book for an appointment on a doctor he/she can cancel there appointment and am using this code for that

private function bookedCell($date)
    {
      $db = DB();
      $user_id = $_SESSION['id'];
      // check if this user made the booking
      $query = $db->prepare('SELECT id FROM bookings WHERE student_id = :id');
      $query->bindParam('id', $user_id, PDO::PARAM_INT);
      $query->execute();
      if ($query->rowCount() > 0) {
        $res = $query->fetchAll();
        return '<div class="booked">' . $this->deleteForm($this->bookingId($date)) . '</div>';
      }
    }

I want to show the cancel button to the users who made the booking but now the delete button is shown for everyone

Jul
17
4 months ago
Activity icon

Replied to Play Video On Hover Using Javascript

I've been trying using jquery but the video not starting when I hove over the container here is the code I've tried

<div class="img-wh m-center" id="parent-{{ $game->g_page_link }}">
					<a href="/browser-game/{{ $game->g_page_link }}" title="Play {{$game->g_name}}">
						<picture id="img-{{ $game->g_page_link }}">
						  <source media="(max-width: 990px)" data-srcset="{{ asset('storage/browsergames-images/'.$game->g_page_link.'/sm_'. $game->g_main_img) }}" class="w-100 h-100 m-center lazy">
						  <source media="(min-width: 991px)" data-srcset="{{ asset('storage/browsergames-images/'.$game->g_page_link.'/'. $game->g_main_img) }}" class="w-100 h-100 m-center lazy">
                          <img data-src="{{ asset('storage/browsergames-images/'.
                          $game->g_page_link.'/backup_'. $imgName.'.jpg') }}"
                           class="w-100 h-100 m-center lazy rounded"
                            alt="{{ $game->g_name }} Browser Game" title="Play {{ $game->g_name }} Now">
						</picture>
						<video loop preload="none" muted id="vid-{{ $game->g_page_link }}">

						</video>
						<script>
							$(document).ready(function(){
								videoFile = "{{asset('a.mp4')}}";
								$("#parent-{{ $game->g_page_link }}").on('mouseenter', function(){
									$("#vid-{{ $game->g_page_link }}").attr('src', videoFile);
									$("#img-{{ $game->g_page_link }}").addClass('d-none');
									
								});
							});
						</script>
					</a>
				</div>