ahmadsiddeeq0

Member Since 4 Months Ago

Mosul

Experience Points
8,010
Total
Experience

1,990 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
73
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

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

Level 2
8,010 XP
Apr
07
1 month ago
Activity icon

Started a new Conversation AJAX .load With Pagination

first i use .load function in AJAX so i can check if there is new posts and load it without page reload. the problem is that i use paginate as well and when i am on the second page (of the paginate) and when the .load fires up it will show the first 10 records instead of the second 10 records despite i am on the second page !

      <script>

setInterval(function() {
    var screen = $('#scre');

    screen.load('/indajax').fadeIn();
}, 10000);

      </script>


<div id="scre" >
@forelse ($posts  as $ite => $post)

......

@empty
......
@endforelse
</div>

<div class="px-2 pt-3 mx-auto  max-w-xl flex flex-col ">
{{ $posts->links() }}
</div>

my controller:

    public function index()
    {
        $blo =  DB::table('blocks')->where('block_id',auth()->user()->id)->pluck('user_id');
        $blofro =  DB::table('blocks')->where('user_id',auth()->user()->id)->pluck('block_id');
        $posts =  DB::table('posts')->join('users','posts.user_id','=','users.id')->select('posts.user_id as userid','posts.id as id','posts.created_at as date','posts.update
d_at as update','users.id as userid','users.username as username','users.first_name as first_name','users.last_name as last_name','users.profile_photo_path  as profile_photo_
path','posts.image as image','posts.content as content')->WhereNotIn('posts.user_id',$blo)->WhereNotIn('posts.user_id',$blofro)->orderBy('posts.created_at', 'desc')->paginate(10);
        $i=0;
        $j=0;
        $cou=$posts->count();

        return view('index',compact('posts','i','j','cou'));
    }

i know the .load will load the records from the beginning , so how can i prevent that from happening

Mar
26
1 month ago
Activity icon

Replied to Pagination Vertically

i pressed best answer by mistake

Activity icon

Replied to Pagination Vertically

i did not know that but i am doing it with jquery

Activity icon

Replied to Pagination Vertically

sorry but do have a simple example about that

Activity icon

Started a new Conversation Pagination Vertically

does laravel had vertical pagination like "load more " or not because i make this with traditional paginate :

<script type="text/javascript">

 var page = 1;
 var urll = $(location).attr('href');
 if(urll != '{{ asset('/posts') }}'){
  Turbolinks.visit('/posts');
 }
 $(window).scroll(function() {
     if($(window).scrollTop() + $(window).height() >= $(document).height() && urll == '{{ asset('/posts') }}') {
         page++;
         loadMoreData(page);
     }
 });
 function loadMoreData(page){
   $.ajax(
         {
             url: '?page=' + page,
             type: "get",
             beforeSend: function()
             {
                 $('.ajax-load').show();
             }
         })
         .done(function(data)
         {
             if(data.html == " "){
                 $('.ajax-load').html("No more records found");
                 return;
             }
             $('.ajax-load').hide();
             $("#post-data").append(data.html);

         })
         .fail(function(jqXHR, ajaxOptions, thrownError)
         {
                 $('.ajax-load').show();
         });
 }


</script>

but it did not remember my previous position because of

  Turbolinks.visit('/posts');

if i did not add this code bellow and i liked a post (via a link that [toggle elequent that does the like functionality] ) it will still load the first page infinitely when i scroll to the buttom:

 if(urll != '{{ asset('/posts') }}'){
  Turbolinks.visit('/posts');
 }

what i ment to say is :

*adding 'Turbolinks.visit('/posts')' causes not remembering the previous scroll position

*removing 'Turbolinks.visit('/posts')' with like a post causes infinitely reloading the first page

so i have to either remove 'Turbolinks.visit('/posts')' and having infinite 1st page scroll or adding 'Turbolinks.visit('/posts')' and not having Preserving Scroll Position (imagine how annoying to go to the top if you are at the buttom of the page just because you liked a post )

is there any pagination vertically built in laravel natively ? or am i doing this wrong and should stay in normal horizontal scrolling (but it is so annoying and my app aiming for mobile users and scroll in vertical is much easier than horizontal ) thanks in advanced

Mar
09
2 months ago
Activity icon

Replied to Hide/show A Div Inside A Laravel Forelse Loop For Each Iteration

in console : Uncaught TypeError: x is undefined

Activity icon

Started a new Conversation Hide/show A Div Inside A Laravel Forelse Loop For Each Iteration

hi I am trying to hide/show a div inside a laravel forelse loop for each iteration so i did something like that in my script :

function comclo(){
  
        var x = document.getElementsByClassName("comclo")[{{$ite}}];
    if (x.style.display === "none") {
      x.style.display = "block";
    } else {
      x.style.display = "none";
    }
  
  }

and the button toggle

<button onclick="comclo();">
      <i class="far fa-comment"></i>
        </button>

and my div that i want to hide / show

 <div class="flex flex-wrap -mx-3 mb-6 comclo"  style="display:none;">
..........
</div>

as far as i can tell the problem in this line

        var x = document.getElementsByClassName("comclo")[{{$ite}}];

because if i did it lke that it will work for the first one

        var x = document.getElementsByClassName("comclo")[0];

and this work for the second one

        var x = document.getElementsByClassName("comclo")[1];

the forelse statment is :

@forelse ($posts as $ite => $post)

how can i make $ite the index of the class in getElementsByClassName ?

update : i tried to use

        var x = document.getElementsByClassName("commec")[{{$loop->index}}];

but still nothing when i click the button thanks in advanced

Feb
21
2 months ago
Activity icon

Replied to X-jet-validation-errors Not Working With Ajax

sorry but do you have step by step how to make that happen

Activity icon

Replied to X-jet-validation-errors Not Working With Ajax

does livewire page refresh by default ? i googled it but i could not find any one that make it without page reload

Activity icon

Started a new Conversation X-jet-validation-errors Not Working With Ajax

first of all sorry because I ask too many questions here

I have laravel auth with livewire and I am making it as SPA as possible so here is my code:

<form id="reg" method="POST" action="{{ route('login') }}">
....
</form>



<script>

 $("#reg").submit(function(e) {
e.preventDefault(); 
var form = $(this);
var url = form.attr('action');

$.ajax({
       type: "POST",
       url: url,
       data: form.serialize(), 
       success: function(data)
       {
        Turbolinks.visit('/home');

        



       },
     
       error: function (error) {
		/*Turbolinks.visit('/login');*/
        /* window.location.replace("/login"); */

    }



     });


}); 
</script>

the problem is that x-jet-validation-errors does not work well with ajax jquery

        <x-jet-validation-errors id="close" class="mt-8 text-left text-indigo-500"  />

i tried this inside the error function :

Turbolinks.visit('/login');

but it will not work because it will not catch the error also

i tried

window.location.replace("/login");

will not work because it will act as reload page but without the error

i think i have to pass the error ( if there is ) through submit but i prevent that due to ajax . or i passed the error but i can not get the error because the page will not be refresh due to ajax

what should i do ?

thanks in advanced

Feb
19
2 months ago
Activity icon

Started a new Conversation Variable In .load Jquery

i want to get data with out page refresh and i have this

setInterval(function(){
        $("#screen").load('comajax/',$post->poid)
        }, 1000);

the problem is that jquery (or javascript) can not detect the variable $post->poid i spent my day trying to get it working but i could not :( i have #screen div and the $post->poid is correct out of javascript .

Feb
12
2 months ago
Activity icon

Replied to Livewire Or Inertia

i saw jeffry using turbolinks but i did not understand it

and there is no good documentation for it

do you have any tutorials on turbolinks ?

thanks

Activity icon

Started a new Conversation Livewire Or Inertia

long story short i want my website to be SPA as easy as possible

should i use livewire or inertia which one is easier ? I know that inertia is not a framework i know basic VUE but not much

also i noticed that you can visit register or login without page reload in auth with inertia but not with livewire so the whole page will reload . is that drawback in livewire (can i make navigate with my website without page reload in livewire ? or i have to go to inertia)

also i don't want to do that with jQuery

sorry for my stupid question thanks in advanced

Feb
05
3 months ago
Activity icon

Awarded Best Reply on Unique Value From 2 Different Loops

when i mergethe i got only one collection instead of 8 so i can filter the 8 out

$tempto =  User::find(auth()->user()->id)->id;

$frommer =  Message::join('users','messages.from_user','=','users.id')
        ->select('users.username as username','users.first_name as first_name','users.last_name as last_name','users.profile_photo_path as profile_photo_path','messages.mescont as mescont','messages.from_user as from_user','messages.to_user as to_user','messages.read as read')
        ->where('to_user', $tempto)
        ->orwhere('from_user', $tempto)
        ->get()
        ->unique('from_user');
        $tomer =  Message::join('users','messages.to_user','=','users.id')
        ->select('users.username as username','users.first_name as first_name','users.last_name as last_name','users.profile_photo_path as profile_photo_path','messages.mescont as mescont','messages.from_user as from_user','messages.to_user as to_user','messages.read as read')
        ->where('to_user', $tempto)
        ->orwhere('from_user', $tempto)
        ->get()
        ->unique('to_user');


        $me= $frommer->merge($tomer);
        ddd($me);

the output

 #attributes: array:8 [▼
        "username" => "dd"
        "first_name" => "d"
        "last_name" => "d"
        "profile_photo_path" => null
        "mescont" => "g"
        "from_user" => 1
        "to_user" => 4
        "read" => null
      ]
Feb
03
3 months ago
Activity icon

Replied to Unique Value From 2 Different Loops

this is not the real problem for me :(

Activity icon

Replied to Unique Value From 2 Different Loops

i am sorry if i write this in a wrong way i am noob in laravel

but i use this to get the id of the auth user

Activity icon

Replied to Unique Value From 2 Different Loops

when i mergethe i got only one collection instead of 8 so i can filter the 8 out

$tempto =  User::find(auth()->user()->id)->id;

$frommer =  Message::join('users','messages.from_user','=','users.id')
        ->select('users.username as username','users.first_name as first_name','users.last_name as last_name','users.profile_photo_path as profile_photo_path','messages.mescont as mescont','messages.from_user as from_user','messages.to_user as to_user','messages.read as read')
        ->where('to_user', $tempto)
        ->orwhere('from_user', $tempto)
        ->get()
        ->unique('from_user');
        $tomer =  Message::join('users','messages.to_user','=','users.id')
        ->select('users.username as username','users.first_name as first_name','users.last_name as last_name','users.profile_photo_path as profile_photo_path','messages.mescont as mescont','messages.from_user as from_user','messages.to_user as to_user','messages.read as read')
        ->where('to_user', $tempto)
        ->orwhere('from_user', $tempto)
        ->get()
        ->unique('to_user');


        $me= $frommer->merge($tomer);
        ddd($me);

the output

 #attributes: array:8 [▼
        "username" => "dd"
        "first_name" => "d"
        "last_name" => "d"
        "profile_photo_path" => null
        "mescont" => "g"
        "from_user" => 1
        "to_user" => 4
        "read" => null
      ]
Activity icon

Replied to Unique Value From 2 Different Loops

that's what i want to do but in laravel

Activity icon

Started a new Conversation Unique Value From 2 Different Loops

how can i prevent duplication from second loop that is already been in the first loop

for example the first loop start (and cycling through an giving)

1
2
3

and the first loop finishes the second loop start (and cycling through an giving)

2
3
4

i want the resault:

1
2
3
4

NOT

1
2
3

2
3
4
Jan
25
3 months ago
Activity icon

Commented on Build A Like/Dislike System

@jeffreyway is it possible to use (unpack turbolinks) with the likes and dislikes ?

Jan
23
3 months ago
Activity icon

Commented on Understanding Foreign Keys And Database Factories

faker is the lorem ipsum in laravel

Jan
19
3 months ago
Jan
16
3 months ago
Activity icon

Replied to Am I Writing Laravel The Right Way !

i watched alot a watched 4 hours and another one 2 hours and 2 tutorial series and another hour and more

Activity icon

Replied to Am I Writing Laravel The Right Way !

i figure it out

Jan
15
3 months ago
Activity icon

Replied to Am I Writing Laravel The Right Way !

i watched a lot of tutorial now its time to get my hands dirty by writing code

Jan
14
3 months ago
Activity icon

Replied to Am I Writing Laravel The Right Way !

thanks for your kind word

thanks

Activity icon

Replied to Am I Writing Laravel The Right Way !

that did not work instead i did :

$po =  DB::table('follower_user')->select('user_id')->where('follower_id', '=', auth()->user()->id)->pluck('user_id');
$posts = Post::with('user')->where('user_id', $po)->get();

it is working if the user has one following

Activity icon

Replied to Am I Writing Laravel The Right Way !

omg that was hard

Activity icon

Replied to Am I Writing Laravel The Right Way !

when i put :

        $po =  DB::table('follower_user')->select('user_id')->where('follower_id', '=', auth()->user()->id)->get();
        $posts = Post::with('user')->where('user_id', $po)->latest();

the page is empty

[i have colomn in my follower_user table for user_id and follower_id ]

Activity icon

Replied to Am I Writing Laravel The Right Way !

my user model


 public function post()
{
    return $this->hasMany(Post::class);
}

    public function followings()
    {
        return $this->belongsToMany(User::class, 'follower_user', 'follower_id', 'user_id');
    }

    public function followers()
    {
        return $this->belongsToMany(User::class, 'follower_user', 'user_id', 'follower_id');
    }


my post model

 public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function like()
    {
        return $this->belongsToMany(Like::class, 'likes', 'post_id', 'user_id');
    }
Activity icon

Started a new Conversation Am I Writing Laravel The Right Way !

hi i am new to laravel

i just want to know if i am writing laravel the right way !

i have a small project that have users and each user has a posts and each post has comments

so if i want to show all the comments i did something like that :


$posts =  DB::table('posts')->join('users','posts.user_id','=','users.id')->select('users.id as pusid','posts.created_at as phdate','posts.updated_at as phupdate','posts.image as image','posts.content as content','users.first_name as first_name','users.last_name as last_name','users.username as username','users.profile_photo_path as profile_photo_path','posts.id as poid','posts.user_id as usid')->where('posts.id', '=', $post)->get();


$comments =  DB::table('comments')->join('users','comments.user_id','=','users.id')->join('posts','comments.post_id','=','posts.id')->select('comments.created_at as date','comments.post_id as postid','comments.user_id as userid','comcont','posts.created_at as phdate','posts.updated_at as phupdate','posts.image as image','posts.content as content','users.first_name as first_name','users.last_name as last_name','users.username as username','users.profile_photo_path as profile_photo_path')->where('post_id', '=', $post)->get();
        
return view('show',compact('posts','comments'));

i made it like that because i want to show the user's info also the post itself and the comments info so i joined them and because all these tables have created at and updated at (duplicate colomn on join) and i want to see the post's date and comments' date so i wrote as , as ,as ..... several times

that worked for me but : is it the only way (probably not. i feel like i am writing laravel as pure php )! is it the right war (probably not . i heard that laravel is so powerful because of its syntax and easy short syntax ) any thoughts on that . sorry for this long question and thanks in advanced

Jan
11
3 months ago
Activity icon

Replied to The Profile Picture In Jetstream Dashboar

open .env and change "APP_URL=http://blog.test" to "APP_URL=http://127.0.0.1:8000"

in config/jetstream.php uncomment "Features::profilePhotos(),"

$ rm -rf public/storage && php artisan storage:link

Jan
05
4 months ago
Activity icon

Replied to Where Are You All From?

Mosul Iraq

Activity icon

Replied to My Avater Is Not Visible

in config/jetstream .php uncomment "Features::profilePhotos(),"

remove public/storage folder if exist

$ php artisan storage:link

and now it should work