mabdullahsari

mabdullahsari

Member Since 11 Months Ago

Experience Points
30,870
Total
Experience

4,130 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
0
Lessons
Completed
Best Reply Awards
52
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 7
30,870 XP
Aug
05
4 days ago
Activity icon

Replied to Testing With An Authenticated User

The error explicitly tells you what's wrong. But you're looking somewhere completely different.

null given

It means $event->user returns not a User model, but null. You'll have to check why that is the case.

Aug
03
6 days ago
Activity icon

Replied to AssertSee Not Working

I cannot tell what the exact issue is by looking at this piece of test code. But this is most likely the culprit:

assertSee escapes the passed argument by default (as of Laravel 6 I think?). This can mean two things:

  1. You are not escaping your content properly in your blade views because you forgot to do so
  2. You intentionally do not want to escape the content and in that case you can pass false as the second argument to assertSee.

"long HTML line of code" is very normal as it is trying to find that piece of information in your HTML response.

Jul
22
2 weeks ago
Activity icon

Replied to Vuex: Sidebar Is Not Toggling With The Value Of A State

It's explained in the official docs: https://vuex.vuejs.org/guide/state.html

You have to map the state so Vue can detect changes and actually rerender your component.

computed: mapState([
  'sidebartoggle'
])

// in your template
<div id="wrapper" class="toggled" v-if="sidebartoggle">
Jul
21
2 weeks ago
Activity icon

Replied to Invisible Laravel-debugbar

No. You will have to use Telescope.

Jul
20
2 weeks ago
Activity icon

Replied to PDF To HTML Conversion

Yeah they are, my bad. Read the topic without drinking my morning coffee. Woops. Ignore me 🙈

Jul
19
3 weeks ago
Activity icon

Awarded Best Reply on Trying To Display Single Post Returns 404 Not Found

findOrFail is not going to work because it matches the model's id by default.

Adjust your query:

Post::query()->where('slug', $slug)->firstOrFail();
Activity icon

Awarded Best Reply on Selection Precise Eoquent Relation Based On User Id - Possible?

You're probably using a PHP version < 7.4

Try this:

Model::query()
    ->with(['basket' => static function ($builder) {
        $builder->where('user_id', auth()->id());
    }])
    ->get();
Activity icon

Replied to How To Safely Store Code In DB?

You can simply store it in a textfield as is as long as you do not render the contents as raw html when using it.

So, don't do {!! !!} in case of Blade.

Activity icon

Replied to Trying To Display Single Post Returns 404 Not Found

Same end result, different approaches.

Activity icon

Replied to Selection Precise Eoquent Relation Based On User Id - Possible?

You're probably using a PHP version < 7.4

Try this:

Model::query()
    ->with(['basket' => static function ($builder) {
        $builder->where('user_id', auth()->id());
    }])
    ->get();
Activity icon

Awarded Best Reply on Anchor Tag Not Showing

That's default behaviour to protect your application from XSS attacks. You will need to explicitly say that you want to render HTML tags instead of plain text.

You'll need to do something like

<div v-html="data" />

I hope that you sanitize this data before saving it to your database.

Activity icon

Replied to Trying To Display Single Post Returns 404 Not Found

findOrFail is not going to work because it matches the model's id by default.

Adjust your query:

Post::query()->where('slug', $slug)->firstOrFail();
Activity icon

Replied to Anchor Tag Not Showing

That's default behaviour to protect your application from XSS attacks. You will need to explicitly say that you want to render HTML tags instead of plain text.

You'll need to do something like

<div v-html="data" />

I hope that you sanitize this data before saving it to your database.

Jul
18
3 weeks ago
Activity icon

Replied to Selection Precise Eoquent Relation Based On User Id - Possible?

No, it's valid. You can pass an array of relationships as well instead of plain string values. When using an array, you can modify the relationship queries individually.

Activity icon

Replied to Laravel Custom Validation Uses Validate Function Instead Of Passes

Can you show us a snippet of what you're trying to achieve exactly?

Activity icon

Replied to Selection Precise Eoquent Relation Based On User Id - Possible?

You can pass in a Closure to modify the relation query:

Model::query()
    ->with(['basket' => fn ($builder) => $builder->where('user_id', auth()->id())])
    ->get();
Jul
17
3 weeks ago
Activity icon

Awarded Best Reply on Form Spoofing

CSRF is not a protection against spam, but for prevention regarding form submissions that happen against your will. e.g. Someone sends you a link, you click on it and they make a POST request in the background on that web page. CSRF is designed to prevent exactly that.

You will need to implement anti-spam mechanisms, such as https://github.com/spatie/laravel-honeypot Recaptcha is not infallible neither is the link I've provided. You'll need to examine what's happening.

Activity icon

Replied to Form Spoofing

CSRF is not a protection against spam, but for prevention regarding form submissions that happen against your will. e.g. Someone sends you a link, you click on it and they make a POST request in the background on that web page. CSRF is designed to prevent exactly that.

You will need to implement anti-spam mechanisms, such as https://github.com/spatie/laravel-honeypot Recaptcha is not infallible neither is the link I've provided. You'll need to examine what's happening.

Activity icon

Replied to Better Way Of Importing Into Vue/javascript

No, that's not how ES Modules work. There is only a single source of truth and one declaration of the Form class. You can import it in 100 different locations and it will still be declared once, so there is no redundancy.

(Assuming you make use of a decent bundler like Webpack/Rollup)

Jul
15
3 weeks ago
Activity icon

Awarded Best Reply on Combine Two Collections By Condition

collect(array_merge($arr1, $arr2))
  ->groupBy('name')
  ->values()
  ->map(fn ($person) => $person->reduce(fn ($acc, $cur) => $acc->merge($cur), collect()))
  ->each(static function ($person) {
      if (!$person->has('salary')) {
          $person->put('salary', 'unknown');
      }
  })
  ->toArray();

Read up on Collections:

https://laravel.com/docs/7.x/collections

Activity icon

Replied to Combine Two Collections By Condition

@jenya Yes it is. You can just replace them with regular functions if you are below 7.4.

Also, can you mark as solved please? Thank you.

Activity icon

Replied to Combine Two Collections By Condition

collect(array_merge($arr1, $arr2))
  ->groupBy('name')
  ->values()
  ->map(fn ($person) => $person->reduce(fn ($acc, $cur) => $acc->merge($cur), collect()))
  ->each(static function ($person) {
      if (!$person->has('salary')) {
          $person->put('salary', 'unknown');
      }
  })
  ->toArray();

Read up on Collections:

https://laravel.com/docs/7.x/collections

Activity icon

Replied to How To Automated Web Scraping With Laravel

Well, since Laravel uses Symfony behind the scenes you don't need to require any package to crawl web pages inside your code. Take a look at: https://symfony.com/doc/current/components/dom_crawler.html

Add use Symfony\Component\DomCrawler\Crawler; inside your job and you're good to go.

Jul
14
3 weeks ago
Activity icon

Replied to I'm Trying To Send Html Mail

So... what's the question here? 🙄

Activity icon

Awarded Best Reply on Simple Fade Out Component With Vue Js In Laravel

show is some piece of state so it belongs to data:

data() {
    return {
        show: true,
    };
}

hide after let's say a second:

mounted() {
    setTimeout(() => { this.show = false; }, 1000);
}

You should probably read up on the basics of Vue.

Activity icon

Replied to Live Now: Laravel Worldwide Meetup #1: Joseph Silber & Mohamed Said

Too bad the talks were so short. Mohamed's talk was very interesting, but brief.

Activity icon

Replied to Error On Deleting User Account

Have you even run the package migrations? It seems like you have not...

php artisan migrate
Activity icon

Replied to Is Graphql Faster To Develop Than Rest For API?

Switching to GraphQL won't make development magically faster. You will basically have to start over if you choose to do so.

Also, choosing a technology over another technology just because it's faster to developer with is an awfully bad idea.

Activity icon

Replied to Optimize Eloquent Search Function

Pipelines to the rescue: https://youtu.be/7XqEJO-wt7s

How you are going to implement it is up to you, but pipelines are a perfect candidate to introduce here. Will make it much more readable and maintainable.

Highly recommend you take a look at the video above (ignore the fact that it's L6).

Activity icon

Replied to Simple Fade Out Component With Vue Js In Laravel

show is some piece of state so it belongs to data:

data() {
    return {
        show: true,
    };
}

hide after let's say a second:

mounted() {
    setTimeout(() => { this.show = false; }, 1000);
}

You should probably read up on the basics of Vue.

Activity icon

Replied to Better Mail Service For Laravel App

You can use whatever you'd like to use. There is no best. I personally use mailgun.

Activity icon

Replied to Do You Move Controller Methods To Models Or Not?

The controller should only wire up different parts of your application and ideally not have any business logic inside of it.

It will become obvious as your application grows larger and larger.

Also testability plays a huge role.

Activity icon

Replied to Laravel Password Rest Not Working

Would you mind placing some back ticks around your exception stack trace? 😑

Activity icon

Replied to Simple Fade Out Component With Vue Js In Laravel

Why don't you put the styles inside the Vue component?

<style scoped>
...
</style>

You should place a setTimeout in the mounted lifecycle hook that toggles the show flag after an X amount of time so your component can actually fade out. Obviously, don't forget place a v-if="show" on your div.

Jul
13
3 weeks ago
Activity icon

Replied to Question About %like% And Eloquent

Can you delimit your database values? What is actually saved as a separate row.

Activity icon

Replied to Foreign Key Constraint Is Incorrectly Formed

$table->id();
$table->foreignId('category_id')->constrained('categories')->cascadeOnDelete();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete()

You have to create the column before creating the foreign key. foreignId takes care of that.

Activity icon

Replied to Jquery Td To Javascript Td

The thing is, you have to decide whether you want to make use of event delegation or not. In your first example, there is no event delegation even if it looks like it because jQuery does a "foreach" behind the scenes on the selector you have provided.

In your conversion attempt, you are trying to make use of event delegation but it won't be straight forward without a few data attributes to determine the selection of the correct element.

Activity icon

Replied to When Is Accessor Running?

Route before middleware is always run... well before any app/controller logic so everything seems alright. Can you show the accessor code?

Activity icon

Awarded Best Reply on Collection Of Products With Multiple Category IDs

You can use whereIn to pass along the array of ids:

Product::whereIn('id', $ids)->get()
Activity icon

Replied to How To Test Mysql Specific Function In Sqlite

The (unfortunate) simple answer is: you cannot.

You have 3 options:

  • Use something in common rather than a driver specific functionality (e.g. there is a FIELD function is MySQL which you cannot use in SQLite, but you can mimic that function using CASE WHEN statements)
  • Don't test that piece of code (you can use a phpunit group annotation and then mark that group as skipped)
  • Implement 2 separate solutions each for a particular SQL grammar.

I'd personally go for option 1 if possible, and option 2 if not. 100% test coverage is not a must IMHO.

Activity icon

Replied to Collection Of Products With Multiple Category IDs

You can use whereIn to pass along the array of ids:

Product::whereIn('id', $ids)->get()
Activity icon

Awarded Best Reply on Request() Helper Function Issue.

If you take a closer look, you can see that calling the request helper function without parameters returns the current request from IoC container:

if (is_null($key)) {
    return app('request');
}

That's why you see the whole request object. When you call it with a single parameter, it passes the call to the request instance:

 $value = app('request')->__get($key);

Thus returning the GET parameter bound to the current request.

Jul
12
4 weeks ago
Activity icon

Awarded Best Reply on API Resources - Resource Collections - Pagination Meta Data Disappear

Well, if you are going to use a dedicated resource collection class, then you do not have to use the static collection method which returns an AnonymousResourceCollection. At the moment, you are wrapping a collection inside another collection.

It's one or the other, not both.

Activity icon

Replied to Fatal Error: Uncaught Error: Call To A Member Function SetFetchMode() On Bool

Yeah okay my bad, your variables names are confusing.

Are you sure your connection string is correct? query returns false probably.

Activity icon

Replied to Fatal Error: Uncaught Error: Call To A Member Function SetFetchMode() On Bool

Place the setFetchMode above your query (select * from data).

You need to do the configuration before executing the query.

Activity icon

Replied to API Resources - Resource Collections - Pagination Meta Data Disappear

Well, if you are going to use a dedicated resource collection class, then you do not have to use the static collection method which returns an AnonymousResourceCollection. At the moment, you are wrapping a collection inside another collection.

It's one or the other, not both.

Activity icon

Awarded Best Reply on How To Retrieve Parameter From Url.intended In A Session ?

One way of solving is parsing the query string and extracting the client_id from it.

See https://www.php.net/manual/en/function.parse-str.php

Jul
11
4 weeks ago
Activity icon

Awarded Best Reply on Pros And Cons Between Laravel Versions

Answering in order:

  1. You have to go through the upgrade guide that gets released along with each major version (6 to 7 for example) and apply the needed breaking changes. You can also use automated upgrade systems such as JMac's Laravel Shift. Generally speaking for minor releases (7.x.x) for example) you do not have to do anything special as there shouldn't be anything breaking.

  2. Yes and no. Reason is answered in point numero uno. There will be breaking changes with each major release. But this does not mean your project will break every single major update because it depends on what parts of the framework you are using. YMMV

  3. If you are starting a fresh project, pick the latest release. No brainer. It will be the most mature and bug-free version of the framework.

  4. When looking up tutorials, do not care about the minor release tags, so the "x" in version 7.x.x let's say. You could be following a tutorial made during Laravel 6's time which is still perfectly valid and viable. Things don't change that often when set in stone. Try looking up information as close to the current version you are using as possible. So don't go and read on Laravel 4 or early versions of 5.

  5. Yes

Good luck!

Activity icon

Replied to Guzzlehttp Problem

@mokrani Remove that URL ASAP. You do not want to throw your API keys out in the public or else you may perfectly become a victim of abuse and get locked out of the service or worse get a spicy invoice thrown at you.

Coming to your question, you are using the API wrong that's why it rejects your call. Check the docs again.