talhaatsix

talhaatsix

Member Since 9 Months Ago

Experience Points
950
Total
Experience

4,050 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
4
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
950 XP
Sep
04
3 months ago
Activity icon

Replied to Get Group Members | Many To Many | Api | Prepare Response

My middle table is group_member

user_id     bigint(20) unsigned             NO      PRI     
group_id    int(10) unsigned                    NO      PRI     
status      enum('pending','member','admin')    NO      pending 
created_at  timestamp   YES         
updated_at  timestamp   YES         

I created model to this table as well

class GroupMember extends Model
{
    public $incrementing = false;
    protected $perPage = 10;

    protected $table = 'group_member';
    protected $casts = [
        'user_id' => 'int',
        'group_id' => 'int'
    ];

    public function group()
    {
        return $this->belongsTo(\App\Group::class);
    }

    public function member()
    {
        return $this->belongsTo(\App\User::class,'user_id')->select('id','avatar','slug','name');
    }
}

Group Model is this


class Group extends Model
{   
    protected $casts = [
        'user_id' => 'int',
    ];
    protected $fillable = [
        'name',
        'slug',
        'about',
        'website',
        'invitation_message',
        'cover',
        'privacy',
        'user_id'
    ];
    
    public function getCoverAttribute($value) {
        $path = env('IMAGES_URL');
        return ($value) ? $path . '/' . $value : '/static/images/user_cover.jpg';
    }

    
    
        public function members()
    {
        return $this->belongsToMany(\App\User::class, 'group_member')->withPivot('status');
    }
}

is used your provided solution .

i get members with pagination that ok

problem is its getting too much info of user

{
    "current_page": 1,
    "data": [
        {
            "id": 1,
            "name": "rrrrrl",
            "email": "rrrrrrrrr",
            "slug": "rrrr-1",
            "type": "1",
            "status": "Active",
            "phone": "159951",
            "country_id": 1,
            "city_id": 6486,
            "is_paid": false,
            "language_id": 1,
            "currency_id": 46,
            "about": "My Bio",
            "profession": "ABC",
            "education": "BSCS",
            "address": "123 street",
            "avatar": "http:\/\/local.qwe.com\/avatars\/1\/aEP5CDsbn4AtHw0Qb1zZoa1uS0aqRUK278RXCZQh.jpeg",
            "cover": "\/static\/images\/user_cover.jpg",
            "email_privacy": "Friends",
            "phone_privacy": "Friends",
            "education_privacy": "Public",
            "location_privacy": "Public",
            "pitch_privacy": "Public",
            "register_date": "2019-07-10 07:25:38",
            "created_at": "2019-07-10 07:21:43",
            "updated_at": "2019-08-31 13:28:30",
            "pivot": {
                "group_id": 1,
                "user_id": 1,
                "status": "pending"
            }
        }
    ],
    "first_page_url": "http:\/\/localhost\/pitchie-laravel-api\/public\/group-members?page=1",
    "from": 1,
    "last_page": 2,
    "last_page_url": "http:\/\/localhost\/pitchie-laravel-api\/public\/group-members?page=2",
    "next_page_url": "http:\/\/localhost\/pitchie-laravel-api\/public\/group-members?page=2",
    "path": "http:\/\/localhost\/pitchie-laravel-api\/public\/group-members",
    "per_page": 1,
    "prev_page_url": null,
    "to": 1,
    "total": 2
}

for member i just want slug , name , avatar thats it...

Sep
03
3 months ago
Activity icon

Started a new Conversation Get Group Members | Many To Many | Api | Prepare Response

I have Users and Groups tables .

Group have many members .

So i create middle table

group_member 
    user_id 
        group_id 
        enum( status : pending/member/admin) 

users and groups have many to many relation

Problem :

i want get only members of a group with pagination