nabilunfarhanun

nabilunfarhanun

Member Since 8 Months Ago

Software Engineer at Colgis

Experience Points 13,260
Experience Level 3

1,740 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 129
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.

09 Jul
1 week ago

nabilunfarhanun started a new conversation Law Of Demeter.

I am new to programming and got introduced to the law of demeter. I am having trouble understanding it.

For example, I have developed a ecommerce related page. In that page, a list of product will be showed with its supplier address. Naturally only supplier's id is in the product page.

So, my solution was to show it like this, {{$product->supplier->address()}}

The product and supplier relation was defined well. So the output was working without any problem.

However, one of the fellow developers suggested I should use something like, {{$product->supplierAddress()}}. And from inside the supplier function I should ask the supplier in question to return it's address.

I understand the idea behind the law of demeter is to create loose coupling. But I feel like still the product object and supplier object are still related to each other.

My question is two fold. Is the other solution better and follow the law of demeter? If yes, then can you provide a scenario where my code will be problematic and not adaptable to change?

Thanks in advance

14 May
2 months ago

nabilunfarhanun started a new conversation Best Practice For Validation And Dry Principle

What I read from the internet is it is good practice to validate both in front end and back end. Front end validation is needed for user friendliness. And back end validation is needed for security.

However how can I follow the dry principle while doing validation in both end?

For example, suppose, I have a form where it will accept password. And the password minimum length is 6. I did the back end validation with form controller and the front end validation with javascript.

However, if somehow the minimum length is changed to 8 then I need to change the length in two places. One is in back end; another in front end. Isn't it violating the dry principle? How can I manage this in such a way that I would need to change in only one place? What is the best practice in this case?

20 Mar
3 months ago

nabilunfarhanun started a new conversation Can I Use Model Function Or Relationship Inside Eloquent?

In my model order.php I have a function called total_cost which returns a number. Can I use this function to run query.

My model is like,

public function total_cost()
    {
        $cost= 0;
        foreach($this->ceremonies as $ceremony)// ceremony is a one to many relationship defined in the model
        {
            $cost+= $ceremony->budget;
        }
// There can be more queries. It is not finalized yet.
        return $cost;
    }

What I want to do is filter my data in my controller something like,

$orders = Order::where(total_cost(),'>',request('input))->get();

But it is not working.

I know I can do the query in controller. However, as there can be changes so I may need to change in two (or maybe more) places. Is there a way to use model functions in eloquent? Is there a better option?

14 Mar
4 months ago

nabilunfarhanun started a new conversation How To Merge Two Eloquent Collection And Then Sort And Paginate?

I am running two queries to get two sets of collection. What I want to do is merge both of them and then sort and paginate it. My code is like,

  $orderhenkans = Orderhenkan::where('kokyakubango',Auth::guard('web')->user()->bango)
                               ->where('kokyakuorderbango',4)
                               ->get()->pluck('bango'); 
  $misyukko1 = Misyukko::whereIn('orderbango',$orderhenkans)
                             ->whereNotNull('yoyakubi')->get();
  
$orderhenkans = Orderhenkan::where('kokyakubango',Auth::guard('web')->user()->bango)
                              ->get()->pluck('bango');
$misyukko2 = Misyukko::whereIn('orderbango',$orderhenkans)
                               ->whereNotNull('yoyakubi')
                               ->whereDate('hanbaibukacd','<',date('Y-m-d'))->get();
                
$misyukkos = $misyukko1->merge($misyukko2)->orderBy('orderbango', 'desc')->paginate(15);

However dd($misyukkos) is showing me the correct data. But I can't use the paginate and orderBy method. How can I do that?

04 Mar
4 months ago

nabilunfarhanun started a new conversation Adding Progress Bar To File Upload

I have a webpage which will take csv file as input. Then it will validate data. Finally, it will be inserted into the database.

I want a progress bar for that. For now I have already implemented a progress bar but only for the file upload part. I don't know how I can show the progress bar of validation and progress bar for database.

Can you show me the right direction?

24 Jan
5 months ago

nabilunfarhanun started a new conversation How Distantly Related Model Can I Access Via Has Many Through?

I am fairly new in Laravel. I understand I can use the relationship "has many through" for distant relationship. But exactly how distant model can I access?

For example, imagine I am creating a political blogs. I have the following models.

affiliations
    id - integer
    name - string (example: conservative, liberal, green etc)

users
    id - integer
    affiliation_id - integer
    name - string

posts
    id - integer
    user_id - integer
    title - string
    body - text

comments
    id - integer
    post_id - integer
    body - string

I understand if I want to get all the posts written by a particular affiliated group I can use the 'has many through' in affiliation model.

My question is if I want to get all the comments on the post which was written by a particular affiliated group then can I use 'has many through'? If I write something like the following in App/Affiliation,

public function comments()
    {
        return $this->hasManyThrough('App\Comment','App\Post', 'App\User');
    }

Will it be ok?

08 Jan
6 months ago

nabilunfarhanun started a new conversation How To Update A Table Without Primary Key?

I have a table name minyuko. But it doesn't have any primary key. So I can't update it.

My model is like,

class minyuko extends Model
{
    protected $table = 'minyuko';
    protected $primaryKey = null;
    public $timestamps = false;
    public $incrementing = false;
}

My controller is like

$minyuko = Minyuko::where('orderbango',$orderhenkan->bango)->where('denpyobango',$master)->first();
   // dd($minyuko); it gives desired result
  $minyuko->denpyohakkoubi = '1970-01-01 01:01:01';
  $minyuko->save();

I am using predefined database. So, adding a primary key is not really a option.