nyel-dev

nyel-dev

Member Since 2 Years Ago

Experience Points 3,160
Experience Level 1

1,840 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 28
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.

10 Apr
5 months ago

nyel-dev started a new conversation Modify Laravel Relationship Eager Loading

I have this relationship in my model:

    class Job extends Model
    {
        public function xref() {
            return $this->hasOne('App\Test', 'id', 'job_id');
        }
    }

and I am calling it on my controller like this:

    $jobs = Job::with('xref')->get();

I was wondering, how can I make a condition inside the model relationship. Like if the relationship xref returns null. I was hoping I could do something like this:

    class Job extends Model
    {
        public function xref() {
            $xref = $this->hasOne('App\Test', 'id', 'job_id');

            if($xref == null) {
                $xref = $this->hasOne('App\NewTest', 'id', 'job_id');
            }

            return $xref;
        }
    }

so basically what I want is check if what I am returning is null and if null, call a new relationship to another table.

Is this possible somehow?

18 Feb
6 months ago

nyel-dev started a new conversation Call A Post Route Using A Button.

Is it possible to do this?

Let's say I have a route like this:

Route::post('test/{id}', function($id) {
return $id
});

and call it by a button?

<a href="website.com/test/1234"> send </a>
07 Feb
7 months ago

nyel-dev started a new conversation How To Pass Data To PATCH

I have this code:

{{ html()->modelForm($role, 'PATCH', route('admin.auth.role.update', $role))->class('form-horizontal')->open() }}

I would like to ask what is the first parameter $role and what is the third parameter $role?

and also how do I pass the data from the form to the controller? What I was doing before is I am passing the ID of the item and the array of values but now my controller is receiving this:

public function update(UpdateRoleRequest $request, Role $role)
    {
        $this->roleRepository->update($role, $request->only('name', 'permissions'));

        return redirect()->route('admin.auth.role.index')->withFlashSuccess(__('alerts.backend.roles.updated'));
    }
15 Jan
8 months ago

nyel-dev started a new conversation How To Unset Appended Data From Model?

Suppose I have an append array in my model, how do I unset them from one of my controller?

29 Nov
9 months ago

nyel-dev left a reply on API That Returns JSON

@CINEK - Hi thanks for your help that solved the duplication but may I ask why was that happening before?

and also by putting "with('getInformation', 'getPictures')" does that mean it is appending the data into the $resort object?

nyel-dev started a new conversation API That Returns JSON

I have this Resort model

class Resort extends Model
{
    protected $hidden = [
        'owner_id', 'created_at', 'updated_at'
    ];

    public function getInformation() {
        return $this->hasOne(ResortInformation::class);
    }

    public function getPictures() {
        return $this->hasMany(ResortGallery::class);
    }
}

and this controller

class ResortController extends Controller 
{
    use App\Resort;

    public function getResortDetails($id) {
        $resort = Resort::find($id);
        $resort->information = $resort->getInformation;
        $resort->images = $resort->getPictures;

        return response()->json(
            $resort
        );
    }
}

How do I append my getInformation and getPictures data into the $resort object?

everytime I use $resort->getInformation or $resort->getPictures, the json is duplicating it

the example is like this

    [
        {
            "id": 1,
            "name": "Test Resort 1",
            "information": {
                "max_people": 10,
                "pools": 1,
            },
            "images": [
                {
                    "image_path": "uploads/1/2018-11/background.jpg"
                },
                {
                    "image_path": "uploads/1/2018-11/1.jpg"
                },
            ],
            "get_information": {
                "max_people": 10,
                "pools": 1,
            },
            "get_pictures": [
                {
                    "image_path": "uploads/1/2018-11/background.jpg"
                },
                {
                    "image_path": "uploads/1/2018-11/1.jpg"
                }
            ]
        }
    ]

this is the exact response the behavior is adding "get_information" and "get_pictures" even though I have not stated it to show

28 Nov
9 months ago

nyel-dev started a new conversation Can I Put If Else Statements Inside Methods Of Models?

just looking for best practice for this stuff

class User extends Authenticatable
{
    public function isAdmin() {
    if($this->privilege === 1) {
            return true;
        }
  
        return false;
   }

    public function isOwner() {
    if($this->privilege === 2) {
            return true;
        }
  
        return false;
    }

    public function isCustomer() {
        if($this->privilege === 3) {
        return true;
        }
  
       return false;
    }
}

something like this

06 Nov
10 months ago

nyel-dev started a new conversation How To Send Template Email Using Sendgrid?

I would like to use my template in sendgrid as the view of my email in may laravel application. How can I possibly do this?

This is my current code:

Mail::raw('Raw string email', function($msg) { $msg->to(['[email protected]']) ->subject('Test email with sendgrid') ->embedData([ 'custom_args' => [ 'test_name' => "Test Name" ], 'template_id' => 'my_template_id' ],'sendgrid/x-smtpapi');

this mail sends the email but it just sends 'raw string email' in the body and it attaches a file 'sendgrid/x-smtpapi' but cant be viewed either to test the template