farhan_aftab

Member Since 1 Year Ago

Quetta

Experience Points
19,570
Total
Experience

430 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
183
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 4
19,570 XP
Apr
10
3 days ago
Activity icon

Replied to LEFT JOIN

Thanks

Activity icon

Replied to LEFT JOIN

$artworks = Artwork::select('artworks.*') ->leftJoin('artwork_shares', 'artworks.id', '=', 'artwork_shares.artwork_id') ->where('artworks.artist_id', $user_id) ->orWhere('artwork_shares.viewer_id', $user_id)->distinct()->get();

Finally I am done

This is what i want

thanks for help

Activity icon

Replied to LEFT JOIN

I need this query to run just to find my artist

$artist = Artist::find(2);

But I need others 2 queries to be merged into one.

$artworks = Artwork::where('artist_id', $id)->get();

foreach($artworks as $artwork) { $artworkShares = $artwork->artworkShares; //... }

The first query you did to fetch artworks that belongsTo a particular artist.

and in the loop you are doing query on every iteration

Apr
09
4 days ago
Activity icon

Replied to LEFT JOIN

Yes I have these models and relationships set But It is executing three queries

But I want to do it in 2 queries

Like 1- Finding artist from db 2- Then finding all of it's artworks and the shared ones

Apr
08
5 days ago
Activity icon

Replied to LEFT JOIN

I am not counting any data

public static function artworks_for_user($user) { return $user->artworks->merge($user->shared_artworks); }

This gives me correct results but It is using two queries but I only want one query which is not working

$user->artworks // hasMany(Artwork::class) $user->shared_artworks() // belongsToMany(Artwork::class)

Apr
07
6 days ago
Activity icon

Started a new Conversation LEFT JOIN

I have 2 tables "artworks" and "artwork_shares"

artworks table is storing arts for different users and any user can share artwork and it will be stored in artwork_shares table.

Artworks schema

id --- title --- image_url ---- artist_id

Artwork_shares Schema

id ---- artwork_id ---- viewer_id

I want to get artworks of a user and as well as arts that are shared with current user

I wrote this query but not working properly

user_id or artist_id ====> is given like user_id is 2 in below query

select distinct artworks.id, title, image_url, artist_id from artworks left join artwork_shares on artwork_shares.viewer_id = '2' and artworks.artist_id = '2'

Please Help

Apr
01
1 week ago
Activity icon

Commented on Form Validation Essentials

When a user provide invalid data using form What is happening in Laravel validation function Is it redirecting you back from where you come .... And if it redirects you so then how laravel maintains the data from previous request Is it using Sessions when you use old helper function to show old data ?

Jan
18
2 months ago
Activity icon

Commented on Prepping The Frontend

I was also having alot of issues installing tailwind

First Update your node version

Follow these steps: https://stackoverflow.com/questions/49877434/how-to-upgrage-node-in-ubuntu

Then Install Tailwind from document

Follow Steps below: https://tailwindcss.com/docs/guides/laravel

Activity icon

Commented on Scoping Projects

Got the Answer: auth()->user()->isNot($project->owner);

Jan
17
2 months ago
Activity icon

Commented on Scoping Projects

auth()->user()->isNot($project->owner_id) Is not working

Give This error

"Call to a member function getKey() on int"