Griehle

Griehle

PHP Developer at National energy Foundation

Member Since 10 Months Ago

Experience Points
16,200
Total
Experience

3,800 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
144
Lessons
Completed
Best Reply Awards
1
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 4
16,200 XP
Nov
08
4 days ago
Activity icon

Replied to Check For Unread Messages In Service Provider OR Ajax Request?

This is covered here. Though this is being done the other way round than the way you describe.

https://laracasts.com/series/laravel-from-scratch-2018/episodes/33

Activity icon

Replied to With() And Where() In Eager Loading

It seems to me like it should work like this

 public function showData($id)
{
        $exams = Exams::with('user')->where('exam_id', $id)->get();
        foreach($exams as $exam)
        {
            echo $exam->user;
        }
 }

Because the with means the user is preloaded. So $exam->user should be available.

Nov
06
6 days ago
Activity icon

Replied to Duplicate Except

I tried doing it that way when you first posted but it still duplicated In the end what I did was create a variable called except, added the keys in the array that was set to that variable and then passed in the single variable. All based on the lead you gave. So Thank you for that. I was working in tinker at first but when I wrote the actual code it struck me to do it the other way based on your first post.

Activity icon

Replied to Duplicate Except

OK. the final answer was

 $school2 = $school->replicate($except = ['dates_not_available']);
Activity icon

Replied to Duplicate Except

Well, that just replicates everything and has no exception for certain values.

Activity icon

Replied to Duplicate Except

Ohh ya. good point. its starts here

  $school = School::find($request->schoolId);
Activity icon

Started a new Conversation Duplicate Except

I would like to replicate an array except for certain values should be empty. I was hoping for something like

 $school2 = $school->replicate(array $except= 'dates_not_available')

But that syntax is not working and nothing I have found so far indicates what would be correct. This is the only documentation I have found on it.

https://laravel.com/api/5.4/Illuminate/Database/Eloquent/Model.html#method_replicate

Oct
21
3 weeks ago
Activity icon

Commented on Basic Eloquent Relationships

There is a tooling series. have you looked at that?

Oct
20
3 weeks ago
Activity icon

Replied to Sync Does Not Copy All

Actually, in case someone in the future needs this I used tinker to arrive at $program->users used a foreach to get single user, discovered a nested array in there. The final answer was

 $program->users->each(function ($user) use($new) {
        $new->users()->attach($user->id, ['type' =>  $user->users->type]);
    });

All credit to bobbybouwmann for initially pointing me in the right direction. Though this is the final solution.

Oct
19
3 weeks ago
Activity icon

Replied to Sync Does Not Copy All

It was a simple eloquent syntax difference. Very much the direction I needed.

     $program->users->each(function ($user) use($new) {
             $new->users()->sync($user->id, ['type' => $user->withPivot('type')]);
        });
Activity icon

Replied to Sync Does Not Copy All

And today when I try it out actually it doesn't work. I did have to change a thing here.

$program->users->each(function ($user) use($new) {
        $new->users()->attach($user->id, ['type' => $user->pivot->type]);
    });

But its returning a 500 error still. it seems that we are cycling through each $program->user as $user , is that correct there? Then attaching to $new the user type by user_id. Am I close here

Oct
18
3 weeks ago
Activity icon

Replied to Sync Does Not Copy All

Thank you for translating that into my particular situation, And even more for linking the Docs so I can better understand wth I am doing here.

Activity icon

Replied to Sync Does Not Copy All

https://laracasts.com/discuss/channels/laravel/relationships-pivot-table-extra-column-sync

this is the answer. I just don't get it still. Saving for later.

Activity icon

Replied to Sync Does Not Copy All

OK. In tinker this happens, if it helps. Its only attaching user_id

  $new->users()->sync($program->users);
   => [
   "attached" => [
   17,
   41,
   29,
   32,
   35,
 ],
 "detached" => [],
 "updated" => [],

]

Activity icon

Started a new Conversation Sync Does Not Copy All

I am trying to duplicate a already existing ... thing. It copies everything into the database using sync() except ONE value which is ONE column in a database. Type. The program_id and user_id values are there. just not type.

    $program = Program::find($request->programId);
    $new = $program->replicate();
    $new->name = 'Copy: ' . $program->name;
    $new->push();
    $new->users()->sync($program->users);
    $new->sponsors()->sync($program->sponsors);
    return $this->sendSuccess($new);

DATABASE

 id  user_id program_id    type  
57    25          15       NULL
Oct
14
4 weeks ago
Activity icon

Replied to Auth User Name Adding In Table

did you include the Auth at the top of the file you are working in.

use App\Http\Controllers\Admin\Auth;
Activity icon

Replied to Updating To Php 7.3

For me the

 brew unlink php && brew link php
 brew services restart --all
 composer global update
 valet start

worked like a charm when upgrading from 7.2 to 7.3 and restarting valet. Which imho is a much better setup than using homestead,do not follow that advice to abandon it.

Oct
08
1 month ago
Activity icon

Replied to Use Individual React Components In Blade Templates

Its more like

 <div id="example"></div>

when in blade with react. But you should also do

 npm install --save-dev react react-dom laravel-elixir-webpack-react.

to install a package for the jsx and then , head into the gulpfile.js at the root of your project and replace

   require('laravel-elixir-vue'); with require('laravel-elixir-webpack-react');

go into webpack.mix.js in the root of your file and change the mix.js('resources/assets/js/app.js', 'public/js') line to mix.react('resources/assets/js/app.js', 'public/js').

Finally, you'll need to go into resources/views/layouts/app.blade.php and update the app.css and app.js files to use the mix() method instead of asset():

Activity icon

Replied to Cannot Complete A Course

*Series still in development. Check back often for updates. [at the bottom of screen]

Oct
01
1 month ago
Activity icon

Commented on The Seven Restful Controller Actions

It sure didn't feel that way. I thought it ended really suddenly as well. Can't wait to see more in this series.

Activity icon

Commented on The Seven Restful Controller Actions

Ahh man. Ohhhh man. Such a tease.

Sep
21
1 month ago
Activity icon

Replied to Resource Route Not Passing Info

Route::resource('Shop', 'ShopController'); This is why?

Activity icon

Replied to Do You Need A Roles Package?

When has less code ever been a bad plan?

Activity icon

Replied to Resource Route Not Passing Info

Is this true if its outside of the class in question? That everywhere its used it must always be capitalized? In this case the var in question was $project, so in the method it was Project $project. And I had to change it from that to Project $Project, in order for it to work. I have long since moved on past this, I was just updating for future visitors. That's the only var I have that issue with. All the rest work as intended.

Activity icon

Replied to Resource Route Not Passing Info

I made the variable with the same capitalization as he Typehint and it worked. Makes ZERO sense to me.

Activity icon

Started a new Conversation Works In Tinker Not In Policy

Why would something return the right data in tinker and not work in a policy? I use

 $product->store->user_id; 

in tinker it return the number so I can use that against auth user in a policy. But in the policy itself I am getting a Trying to get property 'user_id' of non-object error. Why would that be?

Sep
16
1 month ago
Activity icon

Replied to Get This Where This Exists

Big cleanup starts Wednesday thank the Gods. But what a great learning experience running around behind someone else cleaning up their messes until I can just rebuild from scratch.

I gotta say, I love the way you start that thread out. Giving the guy some push. Nice one. But the stack overflow has the answer I was after. Makes me realize how lazy I got at the end of the day to just ask here. haha. You don't even need the badge do you?

Thanks again.

Activity icon

Started a new Conversation Get This Where This Exists

I am really thinking pivot tables are too much hassle. Here is another question. I have types, in a table of Genre that exist. I wanted to list all genres in all stores. however, some of those stores are no longer around. They have been deleted, yet the product and the genre remain. I already know about cascade and all the ways this SHOULD have been built my question is

    $firstGenres = Genre::all();
    $genres = $firstGenre->where(Shop exists )

Shop is on the other side of a pivot table and it keeps telling me there is no shop. So... what do I need to do? get yourself that badge for answering!

Sep
15
1 month ago
Activity icon

Replied to How To Access Method In Child Component ?

Try something more like this.

    <add-task :item="item" :bus="bus" ref="addNewTaskData" />

methods: {
        clearForm() {
           this.bus.$emit('clearForm')
    }

Your Child component is not reachable unless it $emits an event.

https://forum.vuejs.org/t/how-to-call-a-child-component-method/19363

Activity icon

Replied to Pivot Table Data

In doing iit the other way around for me in tinker, like I started at I was able to get with $genre->with('products')->get(); it was that last get() that I had forgotten.

Sep
14
1 month ago
Activity icon

Replied to Pivot Table Data

Awesome. Thanks for the explanation. That way works now. Now I had been querying a specific genre and trying to collect all the products. This gets me that much closer.

Activity icon

Replied to Pivot Table Data

Update: I am now just trying to see genre in connection with any product. I have a list all products page so I am trying this

@foreach($products as $product)
      <ul>
           <li>{{$product->pivot->genre}}</li>
</ul>
 @endforeach

It says "Trying to get property 'genre' of non-object "

I am beginning to doubt the usefulness of pivot tables. :) But I need to learn it all. I appreciate all the help this forum offers.

Sep
13
1 month ago
Activity icon

Replied to Pivot Table Data

Certainly. Type is represented by genre is this. This is the Product model

     public function shop(){
          return $this->belongsTo(Shop::class);
     }

     public function user(){
         return $this->belongsTo(User::class);
     }

     public function genre(){
         return $this->belongsToMany(Genre::class); //->withPivot('genre_id', 'product_id')
     }

And this is the Shop Model

     public function products(){
         return $this->hasMany(Product::class);
     }

     public function user(){
         return $this->belongsTo(User::class);
     }

     public function genre(){
        return $this->hasMany(Genre::class, Product::class);
     }

And finally the Genre Model

    public function products(){
        return $this->belongsToMany(Product::class);
        }

    public function shop(){
         return $this->hasMany(Shop::class);
    }

I am just for now using tinker trying to access it, and again, my main interest would be to go from Genre to a Products collection. Don't know why this one is killing me.

Activity icon

Started a new Conversation Pivot Table Data

I have a Shop, or store, In Tinker I can access it

      $user->shop;

The Shop has Products and the products have types. But there is a pivot table there. So the type name can be anything. however, I cannot access it as

     $product->type;

or even

     $user->shop->product[0]->type; 

I have the relationships set as has many, it saves well everything seems to be working until I try to display the product with these addition. Or better for me. Trying to access the type and show all products. But.. I just cannot suss it. I hope it isn't too vague for help here.

Activity icon

Replied to How To Become Web Development Master?

Going from good to great requires Drinking. Coffee mostly.

Caffeine is taken in and converted to code, but the by-product of that is sarcasm.

But as Microsoft found out Alcohol is also useful. https://xkcd.com/323/

Sep
12
2 months ago
Sep
11
2 months ago
Activity icon

Replied to Do We Need To Create A Migration Table For Every Model?

My OPinion, Yes. Yes you should always write the migration because it can be created with a simple -m as you create your model but what's really nice is those moments when you need to remember what that one column name was, or how it was spelled, or any reference to yoru database like that. You don't need to open up sequel pro and find your tables, you just reference the migration. Oh ya, it's also really sweet for local dev as discussed above. Especially with factories. but that's not this thread.

Sep
10
2 months ago
Activity icon

Replied to Eloquent Is So Slow ...

And then there was Laravel 6

Sep
02
2 months ago
Activity icon

Commented on Two Layers Of Validation

What if I am also adding a user_id in the form of $userId = Auth::user() kind of thing? so that the Project is owned by the creator of it? How do Include it in the Project::create method?

Sep
01
2 months ago
Activity icon

Commented on Cleaner Controllers And Mass Assignment Concerns

Apparently, your variable must have the same capitalizations as the Typehint

Activity icon

Replied to Resource Route Not Passing Info

Ya, IM sure of it. I have watched it 3 times. I bet it's something I missed lessons ago. I am not getting the empty array brackets. I will look for the github, that's good idea.

Activity icon

Commented on Cleaner Controllers And Mass Assignment Concerns

My stuff stopped having anything in it after changing to type hint. Empty array which makes the edit link not work either as the id is blank as well. no idea why yet. worked fine before

Activity icon

Replied to Resource Route Not Passing Info

Its not getting the correct info. I dd() the var and the array I get is not the project array at all.

Activity icon

Started a new Conversation Resource Route Not Passing Info

I was following the 5.7 from scratch tutorial and everything was fine until the controller methods were changed to get Project $project in. Its not passing any id numbers at all the ink all have a blank spot in them where the number should go

  Url/Project/ /edit

What possible things would make it so it suddenly stops working, I bet it's something stupid.

Aug
31
2 months ago
Activity icon

Commented on Routing Conventions Worth Following

I already had a layouts file and the links in it were route(/Projects') they had to be changed to Projects.index and Projects.create respectively. Using the Route:list command resolved this question.

Aug
30
2 months ago
Activity icon

Commented on Routing Conventions Worth Following

I must have missed something. I switched to the Route::resource thing and now all my routes are undefined?

Aug
29
2 months ago
Activity icon

Replied to Undefined Var In Vue.js

In Vue dev tools it gave the layout of it and the name. That didn't narrow it down much because there were many instances so was it mounted, created, data or html? In the end it was html or actually data() where the error was. but there is no good way to find that without hunt and peck style as far as I know because the line number was 56718 which.. my component is not quite that big.

Nothing to really help future peeps out with here.

Activity icon

Started a new Conversation Undefined Var In Vue.js

How do you find an error in vue when all it says is undefined in App.js ? How can I find out where the undefined var is exactly? Which instance of the var in the component?

Aug
28
2 months ago
Activity icon

Replied to Emails Not Sending

Well, I was able to get it to run by entering the command I created, but somehow it is not firing at night, when its supposed to check. The linux is good, its my code that's the issue.