mstrauss

mstrauss

Member Since 3 Years Ago

Web Developer at Self-employed

Experience Points 40,320
Experience Level 9

4,680 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 199
Lessons
Completed
Best Reply Awards 32
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.

15 Sep
10 hours ago

mstrauss left a reply on My Factory Is Not Applied To My Test Cases

@omda

Try updating the default value on your verified column in the migration to 0 (as opposed to false, since it's a boolean field), see below:

public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email');
            $table->string('password');
            $table->boolean('verified')->default(0);
            $table->rememberToken();
            $table->timestamps();
        });
    }

mstrauss left a reply on Updating To Php 7.3

@antlusher

Laravel valet is amazing, and the setup is typically pretty straight forward. I suggest @sarahs74 keeps trying as it is worth it.

mstrauss left a reply on Updating To Php 7.3

Try running brew info php73 and see what is returned.

14 Sep
1 day ago

mstrauss left a reply on Review Model Relationship With Multiple Tables?

Hi @gabotronix

It sounds like you might be after a polymorphic relationship, see more about it here in the docs: https://laravel.com/docs/master/eloquent-relationships#polymorphic-relationships

Or checkout the video on Laracasts about the subject: https://laracasts.com/series/eloquent-relationships/episodes/5

While the name sounds intimidating, it's really not that bad, especially when you have a something to actually apply it to and it's not all abstract.

mstrauss left a reply on 502 Bad Gateway Nginx - Laravel Valet

I've had this happen before as well. If you didn't already, try:

valet restart

Or, uninstall valet and then reinstall. Might be worth checking the PHP version that you are using as well to make sure it's compatible with your version of valet.

php -v

Or, it could be that your version of PHP is missing something essential like fpm

mstrauss left a reply on Pivot Table Data

HI @griehle

Try this instead:

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

Since this is a belongsToMany relationship, $product->genre should return a collection of genres that are associated with that product, so you would have to add the second foreach loop to iterate through those. You shouldn't need to use pivot in this case, that's more for interacting with other columns on the pivot table (like timestamps or whatever).

12 Sep
3 days ago

mstrauss left a reply on Data Can't Update

This uri segment in your post is odd: /new/public/round/. Generally you shouldn't see public in the url for a laravel application. Take a look at your .htaccess file and make sure it is following the standard convention (if that is your intention). Otherwise your going to have to do something like:

Also, if you run php artisan route:list what is the output?

mstrauss left a reply on Data Can't Update

Hi @van1310

It could be the URL you have listed:

"level/"+ id + "/" + level

Maybe it should be:

"exam/level/"+ id + "/" + level

Since your route looks like this:

 Route::get('exam/level/{id}/{level}'

Of course if you are on the exam/ url when submitting the form, this should automatically happen, but sometimes it's best to b explicit.

11 Sep
4 days ago

mstrauss left a reply on Explode() Expects Parameter 2 To Be String, Array Given

Hi @phaider

It seems like $request->tags is already an array. So you may not need to use the explode function. Try to die and dump $request->tags contents and see for yourself:

   dd($request->tags); // die and dump the content 
   $tags = explode(",", $request->tags);
    $floor->attachTags($tags);
08 Sep
1 week ago

mstrauss left a reply on How Can I Make This Code More Simple?

Typically, you would try to handle more of the logic in the controller as opposed to the view, as the presentation layer is supposed to be as "dumb/simple" as possible.

So maybe something like this, in the pluck method, you can grab whatever value need to be iterated over, which should save you from running consecutive foreach loops.

$maps = MapInfo::all()->pluck('value');

$maps = $maps->map(function($value) {
    $decoded = json_decode($value->info, true); 
    return $decoded['info']; 
}); 

return view('pages.home')->with('maps', $maps);

And then in the view:

@foreach ($maps as $value)
    {{$value}}
@endforeach

mstrauss left a reply on Migration : Correct Table (I Added Columns Directly In DB)

Hi @mostafalaravel

Check out below from the docs

The table method on the Schema facade may be used to update existing tables. Like the create method, the table method accepts two arguments: the name of the table and a Closure that receives a Blueprint instance you may use to add columns to the table:

Schema::table('users', function (Blueprint $table) {
    $table->string('email');
});

Use the following command to have the stub of the migration generated:

php artisan make:migration add_extra_colmuns_to_teamleader_tasks_table --table=teamleader_tasks

mstrauss left a reply on 422 (Unprocessable Entity) // CreateError.js:16 Uncaught (in Promise) Error: Request Failed With Status Code 422

Hi @jet

It could be this:

            let _this = this

            axios.post(this.url, data)
                .then(function(res) {
                    const re = res.data
                    _this.personalInfo = data
                    _this.toggle();
                })
                .then(function(err) {
                    console.log(err)
                })

Try using .catch for the error catching block like this:

            axios.post(this.url, data)
                .then(function(res) {
                    const re = res.data
                    _this.personalInfo = data
                    _this.toggle();
                })
                .catch(function(err) {
                    console.log(err)
                })

Also, it appears you are using es6, so you should be able to remove the _this hack to grab the parent context with the arrow function, see below:

            axios.post(this.url, data)
                .then(res => {
                    const re = res.data
                    this.personalInfo = data
                    this.toggle();
                })
                .then(err => {
                    console.log(err)
                })
07 Sep
1 week ago

mstrauss left a reply on Best Approach To Pre-loading Query-intense Calculations

Good luck! And consider adding the laravel debug bar to help you see your query performance.

mstrauss left a reply on How To Get The Latest Entry As Per Product Id

Oh, I see it now. Okay, try this (basically changing the order of @emadiga solution...

$stockin = DB::table('stockins')->latest()->groupBy('Product_id')->get();

The first item in each of the produced group's should be the unique Product ID that has the latest entry.

mstrauss left a reply on Best Approach To Pre-loading Query-intense Calculations

The easy solution seems to be to create one or two new tables that simply keep track of a players total stats per game. And maybe another that tracks the players total lifetime stats. However, that would certainly go against database normalization standards as there would be a substantial amount of redundant data.

Perhaps database indexing is the best solution. For example, if you index the game_id and player_id on the stats table that should boost the performance of future queries. Also, table joins can be quite expensive, so perhaps just query the stats table (don't join with the stats_meta table), and use php logic to convert the stat number into the appropriate statistic (as opposed to handling this in SQL). try a couple different strategies and make your queries as efficient as possible.

mstrauss left a reply on Best Approach To Pre-loading Query-intense Calculations

Okay, I think I am getting the gist of it. But to be sure, you said:

In the Stats table, you have a column called "Stat". This is where, if you are trying to record that an assist happened (the point of this app is you watch basketball film and record when things happen in the game), you would place a 3.

So in the stats table, what are the other columns? For example, if a certain player had three assists in a particular game, would there be three entries in the stats table for them to indicate this? Kind of like below:

stat | game_id | player_id
3         23                46
3         23                46
3         23                46

mstrauss left a reply on How To Get The Latest Entry As Per Product Id

So, from that last post, it appears you want to order the output by the stockins id not the Product_id? And I'm not getting your logic? All of the created_at's are equal in your example. So why is product_id One (1) excluded from your results? Also, are you trying to limit the number of results?

mstrauss left a reply on How To Get The Latest Entry As Per Product Id

You said it:

show all data

What data do you want it to show? I have the ->take(10) included as a limiter. But if you just want one item, you can do this:

$stockin = DB::table('stockins')->latest()->orderBy('product_id')->first();

mstrauss left a reply on How To Get The Latest Entry As Per Product Id

@pbnskd

Try orderBy as opposed to groupBy as I think that is what you are after:

$stockin = DB::table('stockins')->latest()->orderBy('product_id')->take(10)->get();

Grouping by a unique ID doesn't make much sense.

mstrauss left a reply on Best Approach To Pre-loading Query-intense Calculations

Hi @hunterhawley

Can you give a quick example of your actual DB structure?

mstrauss left a reply on How To Get The Latest Entry As Per Product Id

Hi @pbnskd

So you want to get "x" number of the latest enteries? Try the below code, which should get the 10 latest entries. But this will return a collection as opposed to a single object.

$stockin = DB::table('stockins')->latest()->orderBy('product_id')->take(10)->get();

No need to add the created_at in the latest as that is the default option.

22 Aug
3 weeks ago

mstrauss left a reply on Undefined Variable: Users

@drinni

Okay, try updating this section:

  @if(Auth::user()->sroli == "1")
            @foreach($users as $user)
            @if ($users->isNotEmpty())
@foreach

($user as $user) {{$user->name}} 
@endforeach

@endif

To this:

@if(Auth::user()->sroli == "1" && $users->isNotEmpty())
    @foreach

        ($users as $user) {{$user->name}} 
            
    @endforeach

@endif

mstrauss left a reply on Undefined Variable: Users

Thanks @orion

I copied the @foreach statement from the original OP's question, my bad.

@drinni

Can you share the rest of your blade file? I don't see where there are any offsets in the code that is posted.

mstrauss left a reply on Undefined Variable: Users

Hi @drinni

Try pre-defining the $caktoshoferin var before the if statement, like:

 $caktoshoferin = collect(); 
  if(!$sroli){
      $caktoshoferin = User::where('sroli', Auth::user()->sroli)->get();
  }
  return view('admin.products.show',['sroli'=>$sroli,'users'=>$caktoshoferin]);
}

And then in your view, check if the users variable is empty:

@if ($users->isNotEmpty())

    @foreach

        ($user as $user) {{$user->name}} 

    @endforeach

@endif

19 Aug
3 weeks ago

mstrauss left a reply on Two Table Difference Calution

Yup, if you take a look at the core, the redirect method expects parameters like this:

if (! function_exists('redirect')) {
    /**
     * Get an instance of the redirector.
     *
     * @param  string|null  $to
     * @param  int     $status
     * @param  array   $headers
     * @param  bool    $secure
     * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
     */
    function redirect($to = null, $status = 302, $headers = [], $secure = null)
    {
        if (is_null($to)) {
            return app('redirect');
        }

        return app('redirect')->to($to, $status, $headers, $secure);
    }
}

So the second parameter would be he $status which should be if type int. Try it this way instead:

return redirect('/admin/stocks/stocks')->with( ['stocks' => $stocks);

mstrauss left a reply on Two Table Difference Calution

Can you show the whole method in question on your controller. Also, please use

3 backticks (```) before and after your code so it displays in an easier to read format, thanks!

mstrauss left a reply on Two Table Difference Calution

@pbnskd

The new error you mentioned is likely from a different part of your code, likely the return response you are calling after the query.

mstrauss left a reply on Two Table Difference Calution

I think the error is in this line from your original controller query:

->join('stockouts', 'stocks.id', '=product_id', 'stockins.product_id')

Should be:

->join('stockouts', 'stocks.id', '=', 'product_id', 'stockins.product_id')
08 Aug
1 month ago

mstrauss left a reply on Display Attendance Report In Laravel Blade File

Did you include the use App\Employee; import statement at the top of the EmpAttendanceController?

mstrauss left a reply on Display Attendance Report In Laravel Blade File

If you comment out the new code, does the error go away? I can't see how this query would cause that error.

06 Aug
1 month ago

mstrauss left a reply on Display Attendance Report In Laravel Blade File

@abdulbazith

Hmm.. it looks like you are using an _ instead of a - in the below line:

$query->where('att_count', 1);

Per your model properties, I think it should be:

$query->where('att-count', 1);

Can you try that just to see what the result is?

05 Aug
1 month ago

mstrauss left a reply on Display Attendance Report In Laravel Blade File

Hi @abdulbazith

For the new format you mentioned, the below should work:

// controller

 $employees = App\Employee::withCount([
            'emp_attendance',
            'emp_attendance as present' => function (Builder $query) {
                $query->where('att-count', 1);
            }
        ])->get();

// view

                    @foreach($employees as $employee)

                        <tr>
                            <td> {{ $s_no  }}</td>
                            <td> {{ $employee->name }} </td>
                            <td> {{ $employee->emp_attendance_count }} </td>
                            <td> {{ $employee->present_count }} </td>
                            <td> {{ $employee->emp_attendance_count - $employee->present_count }} </td>
                        </tr>

                        @php ($s_no++)

                    @endforeach

There is an assumption that you have created a relationship on the Employee and the EmployeeAttendance models like below:

// Employee model

    public function employeeAttendaces()
    {
        return $this->hasMany('App\EmployeeAttendance ');
    }

// EmployeeAttendance model

    public function employee()
    {
        return $this->belongsTo('App\Employee');
    }

Please also note this will count all employee attendance records for each given employee. If you want to filter down by a given period, you would have to update the query a bit.

mstrauss left a reply on Push To Array Without Add Key

I believe array key assignments are automatic. If it makes sense for your project, try using an object instead. With an object you can provide just the name without an associated value.

mstrauss left a reply on Prevent Changes In Url Route Parameter

HI @kshitizmittal

Perhaps you can use the POST method as opposed to GET so that the id is not exposed in the URI.

03 Aug
1 month ago

mstrauss left a reply on How To Declare This Date Format In Migration

Hi @mostafalaravel

From the docs: https://laravel.com/docs/5.8/eloquent-mutators#date-mutators

Date Formats

By default, timestamps are formatted as 'Y-m-d H:i:s'. If you need to customize the timestamp format, set the $dateFormat property on your model. This property determines how date attributes are stored in the database, as well as their format when the model is serialized to an array or JSON:

So try something like:

Model with the unique date

class YourModel extends Model
{
    /**
     * The storage format of the model's date columns.
     *
     * @var string
     */
    protected $dateFormat = "Y-m-d\TH:i:s\+u'';
}

I wasn't really sure what you were going for with the 00:00, I assumed milliseconds. But be careful with the precision amount and potentially an improper date format (where Carbon might blow up). If there are issues, try storing the dates as a string instead of a date time. Or, and perhaps this is the easier solution depending on your use-case, just store the updated_at field the standard way Y-m-d H:i:s and the use an accessor mutator when pulling the date from the DB:

Model with the unique date

class YourModel extends Model
{
    public function getUpdatedAtAttribute($value)
    {
        $this->attributes['updated_at'] = $value->format('Y-m-d\TH:i:s\+u');
    }
}
02 Aug
1 month ago

mstrauss left a reply on Display Attendance Report In Laravel Blade File

@abdulbazith

I think I see the issue, try this:

 <tbody>

     @php ($s_no = 1)
     <tr>
         <th width=5%> S. No</th>
         <th width=25%> Name</th>
         @foreach ($empatts as $key => $empat)
         <th width=10%>{{ $key}} </th>
       
     </tr>

     @foreach ($empat as $value)
     <tr>
         <td> {{ $s_no  }}</td>
         <td> {{ $value->employee->emp_name}} </td>

       
         <td>
             {{$value->att_count }}

         </td>
   @php ($s_no++)
         @endforeach
     </tr>
 
     @endforeach
 </tbody>
01 Aug
1 month ago

mstrauss left a reply on Making Mock In Setup() Breaks Serialization Of Collection

Sorry, I should have read the question more closely!

mstrauss left a reply on Making Mock In Setup() Breaks Serialization Of Collection

@denniskoster

I'm guessing it's this:

 ->andReturnUsing(function () {
                return 'test';
            })

As the Mockery andReturnUsing method uses a closure that is set as its first argument. If it makes sense in your case, try this instead:

    public function setUp(): void
    {
        parent::setUp();

        Mockery::mock(TestClass::class)
            ->shouldReceive('test')
            ->andReturn('test');
            })
            ->getMock();
    }

mstrauss left a reply on Laravel TDD Post Request In Web Returns 419 Page Expired

I think it has to do with the CSRF token. Try adding:

$this->withoutMiddleware(); 

above $this->withExceptionHandling();.

That should get your test green. But, if you plan on running this from a browser, you will have to be sure that your form includes the CSRF field, see more info on that in the docs: https://laravel.com/docs/5.8/csrf

mstrauss left a reply on Display Attendance Report In Laravel Blade File

@abdulbazith

I think your @foreach structure may be the issue, try this:

<tbody>

     @php ($s_no = 1)
     <tr>
         <th width=5%> S. No</th>
         <th width=25%> Name</th>
         @foreach ($empatts as $key => $empat)
         <th width=10%>{{ $key}} </th>
         @endforeach
     </tr>

     @foreach ($empat as $value)
     <tr>
         <td> {{ $s_no  }}</td>
         <td> {{ $value->employee->emp_name}} </td>
    <td>  {{$value->att_count }} </td>
     </tr>
     @php ($s_no++)
     @endforeach
 </tbody>
31 Jul
1 month ago

mstrauss left a reply on Display Attendance Report In Laravel Blade File

How about using the @foreach directive with the $key/$value like:

@foreach ($empatts as $key => $empat)

    // contains the date
    $key; 

    // contains the other pertinent data, like emp_id, att_count, etc. 
    $empat

    // you may want to loop through the $empat to display its data. 
    @foreach ($empat as $value)
        
        // employee id
        $value['emp_id`]; 
    
    @endforeach 

@endforeach

if you feel that the inner foreach is too messy for a blade file, which I kind of do, you can handle the logic in your controller using the map method on the collection instance.

mstrauss left a reply on Problem With Joining Three Tables And Then Displaying Results In Laravel

Try wrapping that section with the @auth blade directive

@auth

<div class="col-2">
    <h1>Prefered ads</h1>

        @if (isset($preferedAdsResults))
            @foreach ($preferedAdsResults as $preferedAdsResult)
                <div class="row">
                    <a href="{{route('property.show',['id'=>$preferedAdsResult->id])}}">
                        @if ($preferedAdsResult->active == 'A')
                        <button class="btn btn-success" disabled="dissabled">Verified</button>
                        @endif

                        <img  class="img-fluid" src="/storage/{{$preferedAdsResult->main_photo['original_src']}}/{{$preferedAdsResult->main_photo['filename']}}" alt="Card image cap">
                        <button type="button" class="btn btn-lg btn-primary" disabled style="margin-top:10px;">{{$preferedAdsResult->price}} eur</button>
                        <button type="button" class="btn btn-lg btn-primary" disabled style="margin-top:10px;">{{$preferedAdsResult->quadrature}} m<sup>2</sup></button>
                        <button type="button" class="btn btn-lg btn-primary" disabled style="margin-top:10px; margin-bottom:10px;">{{$preferedAdsResult->city}}</button>
                        <hr>
                    </a>
                </div>
            @endforeach
            <div class="row">
                    <div class="col"></div>
                    <div class="col">{{ $preferedAdsResults->links() }}</div>
                    <div class="col"></div>
                </div>
        @endif
</div>

@endauth

mstrauss left a reply on Display Attendance Report In Laravel Blade File

Try something like:

       $empatts = EmpAttendance::where(function ($query) use ($request) {

            if (! empty($request->from_date))
            {
                $query->whereBetween('att_date', [$request->from_date, $request->to_date]);
            }

        })->get()->groupBy('att_date');

Then you'll have a collection grouped by the att_date. And you can do a @foreach in the blade/view to display the results as you wish.

mstrauss left a reply on Problem With Joining Three Tables And Then Displaying Results In Laravel

Would you mind sharing the routes/web file and the view?

mstrauss left a reply on Problem With Joining Three Tables And Then Displaying Results In Laravel

Hmm... Perhaps the route (or controller) should be protected by auth middleware? Do you feel that non-authenticated users should be able to view this URL?

mstrauss left a reply on Problem With Joining Three Tables And Then Displaying Results In Laravel

Hi @gacho

Since the User has a categories relationship, why not just store their preferences as a relationship as opposed to JSON in the user_preferences table?

$user->categories()->saveMany([
   App\Category::where('name', $preferenceOne),
   App\Category::where('name', $preferenceTwo),
]);

Then you can leverage the relationship to get the desired results, something like:

Property::whereHas('category', function (Builder $query) use (Auth::user()) {
    $query->where('user_id',  Auth::user()->id);
})->get();

Or if you want to continue using the JSON field, then the query would look something like:

$userCategories = Auth::user()->user_preferences; //assuming this is in proper array format, if not cast it to an array

Property::whereHas('category', function (Builder $query) use ($userCategories) {
    $query->whereIn('category_name',  $userCategories);
})->get();
30 Jul
1 month ago

mstrauss left a reply on 401 Unauthenticated In Ajax Login...

Hi @jviure

As @mthomas said, seeing some code would make it easier to help. But, maybe because the user's session ended, and you are sending a request from a route that is presumably protected with the auth middleware, that the Laravel responds with a 401 as the user is not authenticated to be actively visiting the given url. In a traditional Laravel app, the user would be redirected back to the login page if their session expired and they tried to refresh the page, assuming the controller method/route has auth middleware.

mstrauss left a reply on Carbon Date Conversión Failing Just In One Date Field Among Others

Can you show the method which is used to insert the data into the DB?

29 Jul
1 month ago

mstrauss left a reply on Task Scheduler "->hourlyAt()" Not Working As Expected

Could it be overlapping? https://laravel.com/docs/5.8/scheduling#preventing-task-overlaps

$schedule->command('do:stuff-1')->hourlyAt(5)->withoutOverlapping(); 
28 Jul
1 month ago

mstrauss left a reply on Empty Varible On Edit Function

Hi @florent6001

Per the docs: https://laravel.com/docs/5.8/controllers#restful-naming-resource-route-parameters

Naming Resource Route Parameters

By default, Route::resource will create the route parameters for your resource routes based on the "singularized" version of the resource name. You can easily override this on a per resource basis by using the parameters method. The array passed into the parameters method should be an associative array of resource names and parameter names:

So maybe in your case it the route resource Laravel may be looking for is achievementsCategory

// singular resource would be achievementsCategory
Route::resource('/achievements-categories', 'AchievementCategoryController');

Maybe change it to:

Route::resource('/achievement-categories', 'AchievementCategoryController');

Or

Route::resource(/achievements-categories', 'AchievementCategoryController')->parameters([
    'achievements-categories' => 'achievement_category'
]);

All that being said, if you are using a resource route and not having issues with the other controller actions (i.e. create, index, etc.) maybe this isn't the underlying issue.