zakaria_tbey

zakaria_tbey

Member Since 2 Months Ago

Experience Points
700
Total
Experience

4,300 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
6
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.

Level 1
700 XP
Sep
06
2 weeks ago
Activity icon

Replied to How To Use Custom Vue Component In Laravel Nova Template?

Go to your component tools.js file & register it like this :

Nova.booting((Vue, router, store) => {
    Vue.component('your-component-name', require('./components/Tool'));
})
Sep
05
2 weeks ago
Activity icon

Replied to Condition A Nova Theme

let me know if you find a solution for this,

a work around is to edit the boot function in the ThemeServiceProvider.php file of the package

    public function boot()
    {
        $locale = \App::getLocale();
        if($locale == 'ar'){
		//original code
        }
    }

Jun
29
2 months ago
Activity icon

Awarded Best Reply on Laravel Nova BelongsTo Field Display Nested Relationship

Hey @richardbishopme ,

It's note a course or courses problem because this is just an example and returning $this->section->course->department->university doesn't return a relationship object therefore it doesn't serve the cause in Nova

But I've found a work around for this using Eloquent Mutators to trick the Student model that i have an university_id attribute in my student table

Here's my work around for anyone who face the same issue

I'm only using Traits to make the code clean & reusable

<?php

namespace App\Traits;

trait BelongsToUniversity
{

    public function initializeAppendAttributeTrait()
    {
        $this->append('university_id');
    }

    public function university()
    {
        return $this->belongsTo('App\University');
    }

    public function getUniversityIdAttribute()
    {
        if(empty($this->section)
            || empty($this->section->course)
            || empty($this->section->course->department)
            || empty($this->section->course->department->university)
        ){
            return null;
        }

        $item = $this->section->course->department->university->toArray();
        return isset($item['id']) ? $item['id'] : null;
    }

    public function setUniversityIdAttribute($attr)
    {
        $this->university_id = $attr;
    }
}

<?php

class Student extends Model
{
    use \App\Traits\BelongsToUniversity;
....

Now you can get a belongsTo university relationship by simply calling (new Student())->university()

Activity icon

Replied to Laravel Nova BelongsTo Field Display Nested Relationship

Hey @richardbishopme ,

It's note a course or courses problem because this is just an example and returning $this->section->course->department->university doesn't return a relationship object therefore it doesn't serve the cause in Nova

But I've found a work around for this using Eloquent Mutators to trick the Student model that i have an university_id attribute in my student table

Here's my work around for anyone who face the same issue

I'm only using Traits to make the code clean & reusable

<?php

namespace App\Traits;

trait BelongsToUniversity
{

    public function initializeAppendAttributeTrait()
    {
        $this->append('university_id');
    }

    public function university()
    {
        return $this->belongsTo('App\University');
    }

    public function getUniversityIdAttribute()
    {
        if(empty($this->section)
            || empty($this->section->course)
            || empty($this->section->course->department)
            || empty($this->section->course->department->university)
        ){
            return null;
        }

        $item = $this->section->course->department->university->toArray();
        return isset($item['id']) ? $item['id'] : null;
    }

    public function setUniversityIdAttribute($attr)
    {
        $this->university_id = $attr;
    }
}

<?php

class Student extends Model
{
    use \App\Traits\BelongsToUniversity;
....

Now you can get a belongsTo university relationship by simply calling (new Student())->university()

Jun
27
2 months ago
Activity icon

Replied to Laravel Nova BelongsTo Field Display Nested Relationship

Hey @richardbishopme ,

Thanks for your reply

I'll need this kind of relationship in many models

I'm using Nova Ajax Select package to load related models

the Admin choose first an University

then he'll choose one of the sections which belongs to the selected university

then he'll choose one of the departments which belongs to the selected university

then he'll choose one of the courses which belongs to the selected department

then he'll choose one of the sections which belongs to the selected course

therefore adding a university_id to the student table is not a solution for me because I'll also need to add department_id and course_id

I believe there's a way to get nested belongsto relationship in laravel, there's a missing piece which i could not figure it out

Activity icon

Started a new Conversation Laravel Nova BelongsTo Field Display Nested Relationship

Hello Guys,

I've been struggling with this problem for the last 48 hours

I would like to add a BelongsTo field to display Universities Drop-down in a Student Resource

Here's my models : Student -> Section -> Course -> Departement -> University

class Student extends Model
{
    public function section()
    {
        return $this->belongsTo('App\Section');
    }
}

class Section extends Model
{
    public function courses()
    {
        return $this->belongsTo('App\Course');
    }
}

class Course extends Model
{
    public function departement()
    {
        return $this->belongsTo('App\Departement');
    }
}

class Departement extends Model
{
    public function university()
    {
        return $this->belongsTo('App\University');
    }
}

I was thinking about something like this :

class Student extends Model
{
    public function university()
    {
        return $this->section->courses->departement->university;
    }
}

But it doesn't really work

Any solution to properly solve this issue ?

staudenmeir/belongs-to-through package may works but not in my case because i have custom local keys and this package doesn't support custom local keys