ftiersch

Member Since 5 Years Ago

Experience Points
136,045
Total
Experience

3,955 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
101
Lessons
Completed
Best Reply Awards
201
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.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 28
136,045 XP
May
01
1 week ago
Activity icon

Replied to Laravel Relationship Confusion ??

Can an article be written by multiple users or why does your user_id need to be in the bridge table?

Activity icon

Replied to Checking If A Value Is Present Using Jquery.inArray()

  1. You're checking an object, not an array
  2. inArray checks values, you are trying to check keys with it :)
Apr
28
2 weeks ago
Activity icon

Awarded Best Reply on Getting An Array To Display Correctly

Just remove the extra array you are putting in ;-)

$array[str_replace(' ', '_', strtoupper($k))] = $v;
Activity icon

Replied to Getting An Array To Display Correctly

Just remove the extra array you are putting in ;-)

$array[str_replace(' ', '_', strtoupper($k))] = $v;
Apr
23
2 weeks ago
Activity icon

Replied to Relationship Not Working On Third Level.

"hasMany" always returns a Collection (even if that collection has 0 or 1 entries).

So your "staffschedules" is a collection of schedules. Each of those schedules has a "days" variable. but you need to decide which one you want. The "staffschedules" variable is just the container for it.

Apr
22
3 weeks ago
Activity icon

Replied to Should You Update Slug?

If you update the slug it might also be a good idea to have a system in place that redirects the old slug to the new one.

Otherwise google will find a lot of 404 pages (which it is not happy about). And if anyone links to your page their links will be dead often (which they are not happy about).

Just imagine I find a cool post on your page and send the link to a friend via email. In the meantime the owner of the post changes the title -> slug gets changed -> the link I sent to my friend doesn't work anymore.

Activity icon

Replied to Cake Php Is Good For Career

Most Job offers I see sound something like "experience in a modern MVC framework like Symfony or Laravel". They know that if you can handle one framework you can easily learn another one so don't focus too much - start learning instead ;-)

Apr
14
4 weeks ago
Activity icon

Awarded Best Reply on Confused On Collections

A collection is a collection of things (as the name implies).

If you ask a person for their name they will tell you.

If you ask a group of people "What's your name?" they will be confused who you're talking to.

In your case PHP is confused because you're talking to a group of objects. :)

Activity icon

Replied to Confused On Collections

A collection is a collection of things (as the name implies).

If you ask a person for their name they will tell you.

If you ask a group of people "What's your name?" they will be confused who you're talking to.

In your case PHP is confused because you're talking to a group of objects. :)

Apr
12
1 month ago
Activity icon

Replied to Laravel Or Not For A Freelancer ?

I'm a (german) PHP freelancer and have specialized on Laravel maybe 3 or 4 years ago. It might take a little longer to find a new client compared to e.g. Symfony but the added enjoyment of development makes more than up for that for me.

And I've noticed in the last year or two that the demand for Laravel developers has definitely risen quite a bit.

Mar
23
1 month ago
Activity icon

Replied to Controlling Array Formation In Eloquent

DisassemblyMock::whereDisMasterId(1)->get()->mapWithKeys(function (DisassemblyMock $disMock) {
	return [$disMock->dis_step_id => [
		'est_time' => $disMock->est_time,
		...
		]
	];
});

That should do it :) Get the data first and then format it afterwards.

Mar
08
2 months ago
Activity icon

Awarded Best Reply on Arrays And Store Method

$post = request()->validate([
            'title' => ['required', 'max:255'],
            'body' => ['required'],
            'image_url' => ['file']
        ]);

This gives you an array with the validated data. So for example like this:

[
	'title' => 'hello',
	'body' => 'world',
	'image_url' => ...
]

This array is a simple array, nothing special about it. So it doesnt have a "save" method.

You need to create an Eloquent model object for that but you can do that FROM your array.

$postObject = new Post($post);

$postObject->save();

Now you create an object from your array data (if you have a Post model). And that object can then be saved to the database with ->save()

Activity icon

Replied to Arrays And Store Method

$post = request()->validate([
            'title' => ['required', 'max:255'],
            'body' => ['required'],
            'image_url' => ['file']
        ]);

This gives you an array with the validated data. So for example like this:

[
	'title' => 'hello',
	'body' => 'world',
	'image_url' => ...
]

This array is a simple array, nothing special about it. So it doesnt have a "save" method.

You need to create an Eloquent model object for that but you can do that FROM your array.

$postObject = new Post($post);

$postObject->save();

Now you create an object from your array data (if you have a Post model). And that object can then be saved to the database with ->save()

Activity icon

Replied to How To Access Eloquent In Vue Component?

Multiple things:

  1. You cannot just access PHP code in VueJS. Vue is in the browser, PHP is on the server. You would need to run an AJAX call to get that value but I'd say it's easier to either pass it in with your reply object or pass it in as a second prop. Then you can also use eager loading to load the count.

  2. Unrelated but this is not very efficient:

return $this->favorites->count();

This would load EVERY favorite into memory and then count the number of favorites in PHP. But since you're only interested in the number you can let the database do the work by changing it to this:

return $this->favorites()->count();

Or you can check the documentation for "eager loading" and the "withCount" query builder method :)

Mar
04
2 months ago
Activity icon

Awarded Best Reply on Model Scope Not Respecting Relationship

You are trying to go on a table "caf" that (probably?) doesn't exist. For your case you need to use whereHas.

public function scopeApproved($query)
{
    return $query->whereHas('caf', function ($query) {
		$query->where('status_id', '>=', 6);
	});
}
Activity icon

Replied to Model Scope Not Respecting Relationship

You are trying to go on a table "caf" that (probably?) doesn't exist. For your case you need to use whereHas.

public function scopeApproved($query)
{
    return $query->whereHas('caf', function ($query) {
		$query->where('status_id', '>=', 6);
	});
}
Activity icon

Replied to Re-use QueryScope As Attribute

You could maybe add something on the model (by adding an additional virtual column when you used the scope, not sure though) - but your question says explicitly that it should work WITHOUT using the scope. And there lies the problem ;-)

Activity icon

Replied to Re-use QueryScope As Attribute

I don't think there is a simple way for that because the scope acts in the database, the attribute would work in PHP. You might be able to make the attribute go "into the database" to determine it but then you'd have an additional DB call every time you check which doesn't sound very performant :)

Mar
03
2 months ago
Activity icon

Replied to Mkdir(): Permission Denied

Have you made sure, that you have spelled everything correctly? Windows is not case sensitive, Mac is.

So on Windows if you use a namespace like this: App\My\Namespace but your actual folder is called "namespace" it would work, on a mac it probably wouldn't.

Mar
02
2 months ago
Activity icon

Replied to PHP Add A Space After The First Character And Then Every Four

$new = substr($old, 0, 1) . " " . chunk_split(substr($old, 1), 3, ' ');

Not pretty though :D

Mar
01
2 months ago
Activity icon

Replied to Ajax - Unable To Pass Data To Controller

So your data actually arrives correctly at the server. I don't understand your problem in that case. What is supposed to happen? Isn't the subscription saved to the database or doesn't it "show up" on screen?

Activity icon

Replied to Ajax - Unable To Pass Data To Controller

Is the request actually sent or does simply NOTHING happen? (you can check in the Network tab in the dev console). If it is sent: Does it contain the data you expected?

Feb
26
2 months ago
Activity icon

Replied to How To Access Helper Method In Laravel By Vuejs

You cannot access a PHP method in VueJS... One runs on the server, one runs in the browser.

Either you pass data from Laravel into your blade and then pass it to VueJS or you can get data from the server via an AJAX call.

Activity icon

Replied to Notify Users That A New Post Has Been Published

$users = User::whereHas('categories')->with(['categories' => $callback])
        ->where('email_updates', 1)->get();

You have to put the category condition into the "whereHas" too :) Right now you're saying "give me users that have categories. And for those user also load the categories with this specific condition".

$users = User::whereHas('categories', function ($query) use ($topicCategory) { $query->where('id', $topicCategory); })->with(['categories' => $callback])
        ->where('email_updates', 1)->get();
Feb
25
2 months ago
Activity icon

Awarded Best Reply on Is It A Good Practice To Add Custom Verbs To Policies?

Of course that's no problem. The base logic only adds the base functionality - CRUD. But your business logic probably has more besides that in order to create value for your customers so you also need to extend the available base functionality.

Activity icon

Replied to How To Update Specific Filed According To A Condition?

Just move the array out of the method call.

$newData = [
	'company_name' => $request['company_name'],
	...
];

if (!empty($imageName)) {
	$newData['company_logo'] = $imageName;
}

Company::find($id)->update($newData);
Activity icon

Replied to Is It A Good Practice To Add Custom Verbs To Policies?

Of course that's no problem. The base logic only adds the base functionality - CRUD. But your business logic probably has more besides that in order to create value for your customers so you also need to extend the available base functionality.

Feb
24
2 months ago
Activity icon

Replied to Unexpected Redirect To Login

Sounds like you lose your session somewhere in between the requests. What session driver do you use? Do you have a session()->flush() somewhere in a middleware maybe?

Activity icon

Replied to Help With Unique User Id

You mean randomly instead of just counting up?

Activity icon

Replied to How To Become A Professional Laravel Developer

Technically? Find someone who pays you to develop something with Laravel for them. That's the definition of "professional".

But I guess you mean a "good" developer?

Exactly as @chaudigv said. Practise and don't get discouraged. Create a hobby project for yourself to see what it's about and what things you can use.

Activity icon

Replied to Retrieving A Loaded Relationship But Do Not Hit Database If Missing

relationLoaded shouldn't actually hit the DB. Are you sure about that one, that the DB Query comes from this part?

Feb
23
2 months ago
Activity icon

Replied to All Properties Of The $request Are A String Type !

https://laracasts.com/discuss/channels/general-discussion/handling-formdata-null-string

That should be the same problem :) The problem is FormData and axios, not on the Laravel side.

Activity icon

Awarded Best Reply on Similar Question: Trying To Get Property 'p_name' Of Non-object

hasMany returns a collection of items, not a single item. And a collection doesn't have the "p_name" attribute. You need to select a specific product from that collection or use a different kind of relationship (hasOne for example).

Activity icon

Replied to Similar Question: Trying To Get Property 'p_name' Of Non-object

hasMany returns a collection of items, not a single item. And a collection doesn't have the "p_name" attribute. You need to select a specific product from that collection or use a different kind of relationship (hasOne for example).

Feb
22
2 months ago
Activity icon

Replied to Return Redirect() Doesn't Redirect To Desired Page

You should check out the internal Laravel validation system :) It does exactly what you need (I think) and makes your controller a lot easier to read and understand. And for custom logic you can also create your own rules to validate a value.

Activity icon

Awarded Best Reply on Return Redirect() Doesn't Redirect To Desired Page

You return a redirect from another method. If you want to stop the flow you need to return from your controllermethod too. Otherwise you return the redirect but it just vanishes since you don't save it anywhere

Activity icon

Replied to Return Redirect() Doesn't Redirect To Desired Page

You return a redirect from another method. If you want to stop the flow you need to return from your controllermethod too. Otherwise you return the redirect but it just vanishes since you don't save it anywhere

Feb
20
2 months ago
Activity icon

Replied to Mail Markdown Messages - Invalid Argument Supplied For Foreach()

Hahaha, happens to everybody! I've spent many hours before to find that comma that shouldn't be there etc :)

Activity icon

Awarded Best Reply on Mail Markdown Messages - Invalid Argument Supplied For Foreach()

$this->$services = $services;

You have an $ after your -> :)

Activity icon

Replied to How To Get The Last Data Of The Day For A Week

You mean something like this?

Data::whereBetween('created_at', [now()->subWeek()->startOfDay(), now()->subWeek()->endOfDay()])->orderBy('created_at', 'DESC')->first();

This would give you only the data from the same day last week (so on thursday it would give you last weeks data from thursday), order that by date descending (so the latest would come first) and then returns the first one (so the latest one).

Activity icon

Replied to Mail Markdown Messages - Invalid Argument Supplied For Foreach()

I think public attributes of the Mailable are by default accessible inside the view if I remember correctly.

Activity icon

Replied to Testing The Relationship Opun Creating A Model In Laravel

If your database is empty during tests you can just check if there is one row inside your user_vendor table after executing the call.

Otherwise you can just get the user from the database with Eloquent like you usually would. It's the same database in your test and your controller :)

Activity icon

Replied to Mail Markdown Messages - Invalid Argument Supplied For Foreach()

$this->$services = $services;

You have an $ after your -> :)

Feb
19
2 months ago
Activity icon

Awarded Best Reply on How Can I Pass Get() Link In Laravel Controller

You mean you need to send a request to that URL? You can use something like Guzzle to send requests but the "get" function doesn't exist in PHP.

Activity icon

Replied to How Can I Pass Get() Link In Laravel Controller

You mean you need to send a request to that URL? You can use something like Guzzle to send requests but the "get" function doesn't exist in PHP.

Feb
16
2 months ago
Activity icon

Replied to Larastan / Double ?>

True, that can definitely be a bitch :D Unfortunately I don't know a tool / solution that can do it already

Activity icon

Replied to How To Merge Array

array_merge_recursive should do the trick I think

Activity icon

Replied to Laravel- Blade How To Output HTML Tag In Double Curly Braces?

Use unfiltered output if you're sure about the source:

{!! !!}