nabilunfarhanun

nabilunfarhanun

Software Engineer at Colgis BD

Member Since 1 Year Ago

Pabna

Experience Points
14,160
Total
Experience

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
136
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 3
14,160 XP
Oct
25
3 months ago
Activity icon

Started a new Conversation How To Handle Exception Inside Controller?

I am trying to upload a file. And if it throws an exception I don't want to see the "whoops" page. Instead it will go back the previous page with a message. This is what I tried,

try {
    $data = Excel::toArray(new Import, request('file'));
} catch (\Exception $e) {
    return back()->withErrors("an exception occured");
}

But it still gives me the whoops page whenever any exception occurs.

This is the exception I am getting(for testing I purposefully limited the memory size)

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Allowed memory size of 62914560 bytes exhausted (tried to allocate 14680064 bytes)

How to solve it?

Aug
20
5 months ago
Activity icon

Started a new Conversation How To Run Query With Model Function?

So, I have a model for products of a website. In the model I use a function to calculate the price of the product. It is something like this,

class Product extends Model
{

    public function price()
    {
        // logic to calculate price
        // this logic may depend on many things and may change in future.
        return $price
    }
}

I can view this successfully in my blade view by using following.

{{ $product->price() }}

However, I want to use it to do some query. There may be other filtering. Those are working fine. But whenever I want to use the return value of price function in the query it is giving an error.

$products = Product::query();
//There may be some other filtering query
$products = $products->where('price()','<',request('maxPrice'));
//Maybe some more filtering query
$products = $products->get();
return view('product',compact('products'));

My question is how can I run query with the price function of my model. Also, if you can think of an alternative way to achieve this then please teach me.

Aug
09
5 months ago
Activity icon

Started a new Conversation How To Dry Up This Part Of My Code?

I am submitting two forms from same page with ajax. One is to create and another is to update. As they look very similar, my gut says their should be a way to dry up this form. But I am not quite getting it. can you please give me tips on how I can dry this up?

This is the first form,

<script type="text/javascript">
        $("#createForm").submit(function(e) {
            e.preventDefault();
            var form = $(this);
            var url = form.attr('action');
            $.ajax({
                    type: "POST",
                    url: url,
                    data: $('#createForm').serialize(),
                    success: function(data)
                    {
                        if(data=="success")
                        {
                            location.reload();
                        }
                        else
                        {
                            var html = "<ul>";
                            for(var dat in data)
                            {
                                for (var x in data[dat])
                                {
                                    html = html+"<li>"+data[dat][x]+"</li>";
                                }
                            }
                            html = html+"</ul>";
                            $("#createErrors").attr("class","alert alert-danger");
                            $("#createErrors").html(html);
                        }
                    }
                });
        });
    </script>

This is the second form,

<script type="text/javascript">
        $("#updateForm").submit(function(e) {
            e.preventDefault();
            var form = $(this);
            var url = form.attr('action');
            $.ajax({
                    type: "POST",
                    url: url,
                    data: $('#updateForm').serialize(),
                    success: function(data)
                    {
                        if(data=="success")
                        {
                            location.reload();
                        }
                        else
                        {
                            var html = "<ul>";
                            for(var dat in data)
                            {
                                for (var x in data[dat])
                                {
                                    html = html+"<li>"+data[dat][x]+"</li>";
                                }
                            }
                            html = html+"</ul>";
                            $("#updateErrors").attr("class","alert alert-danger");
                            $("#updateErrors").html(html);
                        }
                    }
                });
        });
    </script>