JokersMild85

JokersMild85

Member Since 1 Year Ago

Experience Points 3,090
Experience
Level
Lessons Completed 22
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

12 Jan
11 months ago

JokersMild85 started a new conversation PHPunit Tutorial

Can anyone recommend a good tutorial on how to use PHPunit for beginners? I'm watching the "Lets Build a Forum" tutorial on Laracasts and he is using PHPunit but not really explaining how he gets it to work.

04 Jan
11 months ago

JokersMild85 started a new conversation How To Delete Record

What is the proper way to delete a record in Laravel? Does it have to go through the destroy method?

        if(!empty($request['delete']))
        {    
            foreach($request['delete'] as $delete)
            {
                $workout_exercise = WorkoutExercise::findOrFail($delete['id']);
                
                $workout_exercise->delete();
            }
        }
20 Dec
11 months ago

JokersMild85 left a reply on Formatting Form For Update

Maybe this is a bit closer...

<form method="POST" action="{{ route('workouts.update', ['id'=>$workout['workout_id']]) }}">

The error I am receiving is: Missing required parameters for [Route: {$route->getName()}] [URI: {$route->uri()}].

JokersMild85 started a new conversation Formatting Form For Update

Need a little help on how to set up my form action for my update form. Here's what I have:

<form method="POST" action="{{ action('workouts.update', $id = $workout['workout_id']) }}">
    {{ csrf_field() }}
    {{ method_field('PATCH') }}

I have no idea if I'm close or way off here. Any help would be appreciated.

18 Dec
11 months ago

JokersMild85 left a reply on HasMany Relationship Not Working

It works in QueryBuilder but if I use it in a statement like I'm trying to now, that's the error in receiving.

JokersMild85 left a reply on HasMany Relationship Not Working

select isn't a usable method in Eloquent

JokersMild85 left a reply on HasMany Relationship Not Working

$workout->workout_exercises->all();

This worked but is there a way I can return specific columns instead of all of them?

JokersMild85 left a reply on HasMany Relationship Not Working

So how would I retrieve all of the workout_exercises of $workout? The example provided in the documentation still give me the same error?

JokersMild85 started a new conversation HasMany Relationship Not Working

A workout has many workout_exercises:

Workout Model:

class Workout extends Model
{
    //
    protected $fillable = [
        'user_id',
        'name',
        'published_at'
    ];
    
    public function workout_exercises()
    {
        return $this->hasMany('App\WorkoutExercise');
    }
    
    public function user()
    {
        return $this->belongsTo('App\User');
    }
}

A workout_exercise belongs to a workout

Workout_Exercise Model

class WorkoutExercise extends Model
{
    //
    protected $fillable = [
        'workout_id',
        'exercise_id',
        'we_set_num',
        'we_rep_num',
        'we_set_complete',
    ];
    
    public function workout(){
        return $this->belongsTo('App\Workout');
    }

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

When I define my $workout object and then run the following statement, I receive a 'trying to get property on non-object' error

$workout->workout_exercises->get();

Any suggestions?

08 Dec
1 year ago

JokersMild85 left a reply on Method Not Allowed Error

Okay, I fixed the problem.

Instead of my form action using 'route': '''

'''

I changed it to 'action': '''

'''

Can anyone provide any insight into why this would work instead of using 'route' ?

JokersMild85 left a reply on Method Not Allowed Error

Changed the order of my routes so that my custom ones are listed before my resource and I changed the the workouts.step to workouts/step.

Receiving an undefined route error now.

07 Dec
1 year ago

JokersMild85 started a new conversation Method Not Allowed Error

I know I am receiving this error because Laravel thinks the route is not defined but it is. Any assistance would be appreciated. (The route in question is Route::post('workouts.step, '[email protected]')

Here is the route:

Route::resource('workouts', 'WorkoutsController'); Route::post('workouts.step', '[email protected]'); Route::get('workouts/{workout}/addToWorkout', '[email protected]');

Controller:

public function step(CreateWorkoutRequest $request)
{
    $values = $request->input('exercise');
    $workout_name = $request->input('workout_name');

    for($i=0;$i<count($values);$i++)
    {
        $array = explode(",", $values[$i]);

        $exercises[$i]['exercise_id'] = $array[0];
        $exercises[$i]['exercise_type_id'] = $array[1];
        $exercises[$i]['exercise_name'] = $array[2];
    }

    return view('workouts.step', compact('exercises','workout_name'));
}

View:

@extends('layouts.app')

@section('content')

Create New Workout

@if ($errors->any())

@endif

{{ csrf_field() }}
<div class="form-group">
    <h2>Name Workout: </h2>
    <input type="text" name="workout_name">
</div>

@foreach($exercise_types as $exercise_type)

<div class="form-group">
    <h2>{{$exercise_type->exercise_type}}</h2>
    </br>

    @foreach($exercise_type->exercises as $exercise)
        <label for="{{ $exercise->exercise_name }}">{{ $exercise->exercise_name }}</label>
        <input type="checkbox" name="exercise[]" value="{{ $exercise->id }},{{ $exercise->exercise_type_id }},{{ $exercise->exercise_name }}" id="{{ $exercise->exercise_name }}"></br>
    @endforeach

</div>

</br>

@endforeach

@endsection

28 Nov
1 year ago

JokersMild85 left a reply on Assign Attributes To Form Elements

Ok, thank you. Only used it because that is what was being used in the Laracasts tutorial.

JokersMild85 left a reply on Assign Attributes To Form Elements

I'm sorry, I'm still getting used to working in Laravel. Where would this function be placed so I can call it?

JokersMild85 left a reply on Assign Attributes To Form Elements

Don't need to use double brackets if they are already inside the {!! !!} brackets. I had to use double quotes instead of the single quotes in the value parameter to fix that.

@foreach($exercise_type->exercises as $exercise)

    {!! Form::label('exercise_name', $exercise->exercise_name) !!}
    {!! Form::checkbox( 'exercise[]', "{$exercise->id},{$exercise->exercise_type_id},{$exercise->exercise_name}") !!}
    </br>

@endforeach 

Why is it that I can't find an answer for adding an attribute to form elements? This shouldn't be that hard to do.

JokersMild85 started a new conversation Assign Attributes To Form Elements

I asked this question a couple of days ago but the answers I received did not resolve my problem. I am trying to assign attributes to form elements, namely an ID attribute to my form checkboxes. When I attempt to do this, all it does is set all the checkboxes in my form to checked. Any thoughts why this is happening and how to successfully assign my checkboxes an ID attribute?

@foreach($exercise_type->exercises as $exercise)

    {!! Form::label('exercise_name', $exercise->exercise_name) !!}
    {!! Form::checkbox( 'exercise[]', '{$exercise->id}_{$exercise->exercise_type_id}_{$exercise->exercise_name}', ['id' => '{$exercise->exercise_name}'] ) !!}
    </br>

@endforeach
26 Nov
1 year ago

JokersMild85 left a reply on Assign Id Attribute To Form Checkbox Element

Can you please clarify how the example you provided sets the id property of the checkbox element?

JokersMild85 started a new conversation Assign Id Attribute To Form Checkbox Element

I'm trying to assign an id attribute to checkbox elements of my form. What I am writing is causing the checkboxes to be checked by default and not providing an id attribute. Can anyone provide some insight?

Here is the code:

@foreach($exercise_types as $exercise_type)

{!! Form::label('exercise_type', $exercise_type->exercise_type) !!}
@foreach($exercise_type->exercises as $exercise)

    {!! Form::label('exercise_name', $exercise->exercise_name) !!}
    {!! Form::checkbox( 'exercise[]', "{$exercise->id},{$exercise->exercise_type_id},{$exercise->exercise_name}"), ['id' => "{$exercise->exercise_name}"] !!}
    </br>

@endforeach

@endforeach

14 Nov
1 year ago

JokersMild85 left a reply on Undefined Offset Error

Yep, ran dd($values) after I selected 3 checkboxes and it returned 3 values for each array: sets, reps, and e_id. Not sure why it is looking for a 4th array key.

JokersMild85 left a reply on Undefined Offset Error

They all exist. I'm inspecting the elements of the page and they are all returning values.

JokersMild85 started a new conversation Undefined Offset Error

No idea why I am getting this error, can anyone provide some guidance?

public function store(Request $request)
{
    $values = $request->all();
    $id = Auth::id();
    
    echo "<h2>User ID: ".$id."</h2>";
    
    for($i=0;$i<count($values);$i++)
    {
        $e_id = $values['e_id'][$i];
        echo "<h4>Exercise ID: ".$e_id."</h4>";
        $sets = $values['sets'][$i];
        echo "<h4>Sets: ".$sets."</h4>";
        $reps = $values['reps'][$i];
        echo "<h4>Reps: ".$reps."</h4>";
    } 

}
11 Nov
1 year ago

JokersMild85 started a new conversation Problem Retrieving Values From Imported Array

I'm receiving an error when I try to output some values from an array. The error I'm receiving is "Trying to get property of non-object". Can someone take a look at my code and see what I'm doing wrong?

Controller method:

public function step(Request $request)
{
    $values = $request->input('exercise');
    
    for($i=0;$i<count($values);$i++){
        $array = explode("-", $values[$i]);
        
        $exercises[$i]['exercise_id'] = $array[0];
        $exercises[$i]['exercise_type_id'] = $array[1];
        $exercises[$i]['exercise_name'] = $array[2];
    }

    return view('workouts.step', compact('exercises'));
}

Code from the view:

@foreach($exercises as $exercise)

{{ $exercise->exercise_name }}

@endforeach

Right now I'm just trying to get output from one of the array keys , exercise_name.

10 Nov
1 year ago

JokersMild85 started a new conversation Save Multiple Checkbox Values To $request Array And Retrieve Them

I'm trying to save multiple checkbox values from my form to the $request array but it is only saving one checkbox value.

Here is my code:

Here is the form:

@foreach($exercise_type->exercises as $exercise)

    {!! Form::label('exercise_name', $exercise->exercise_name) !!}
    {!! Form::checkbox( 'exercise[]', "{$exercise->id}-{$exercise->exercise_type_id}-{$exercise->exercise_name}") !!}
    </br>

@endforeach 

Here is the code for retrieving the Request array values:

public function store(Request $request)
{
    $values = $request->input('exercise');
    
    return $values;
}
08 Nov
1 year ago

JokersMild85 left a reply on Foreach Loop In HTML Form Builder Form

Gotcha, didn't realize that's what you were doing. I appreciate the help, thank you.

JokersMild85 left a reply on Foreach Loop In HTML Form Builder Form

That did it, thanks. Is it possible to string those multiple variables together in the second parameter?

JokersMild85 started a new conversation Foreach Loop In HTML Form Builder Form

I wish I could more eloquently explain what I am trying to accomplish here but I am still quite new to Laravel so please forgive if I misuse any terminology in my explanation.

I am trying to apply a foreach loop to my form that I built using the Laravel Collective HTML Form Builder (...correct?) and apply the values I pull from the database to the value fields of the form.

The output it is giving me is what is literally typed in my code. I know its because of the single quotation marks but if I remove them I get a syntax error for not including them.

Here is my code below as it will probably explain what I am trying to do better than how I am describing it.

The controller create function:

public function create()
{
    //
    $exercise_types = ExerciseType::all();
    
    return view('workouts.create', ['exercise_types' => $exercise_types]);
}

The create view:

@extends('layouts.app')

@section('content')

Create New Workout

{!! Form::open(['url' => 'workouts']) !!}

@include ('workouts.form', ['submitButtonText' => 'Create Workout'])

{!! Form::close() !!}

@endsection

The form view itself:

@foreach($exercise_types as $exercise_type)

{!! Form::label('exercise_type', '{{ $exercise_type->exercise_type }}:') !!}
@foreach($exercise_type->exercises as $exercise)

    {!! Form::checkbox( '{{ $exercise->exercise_name }}', '{{ $exercise->id }}-{{ $exercise->exercise_type_id }}-{{ $exercise->exercise_name }}') !!}

@endforeach

@endforeach

{!! Form::submit($submitButtonText, ['class' => 'btn btn-primary form-control']) !!}

Any guidance would be appreciated.

07 Nov
1 year ago

JokersMild85 left a reply on Set Logout Route In Laravel 5.5

Neither of these solutions resolve the problem. I receive the timeout page if I logout of my session immediately after logging in.

I did not delete the {{ csrf_field() }} from the logout form.

The only thing I did that I think began this problem was changing the redirect on login from the default Home page to a different page.

06 Nov
1 year ago

JokersMild85 started a new conversation Set Logout Route In Laravel 5.5

Not sure what I did but when I logout of my session it redirects to a weird timeout due inactivity page on my site. Does anyone know where I can set my route on logout?

JokersMild85 left a reply on Archived Video Series

Working for me now in the original browser 1 hour after trying the first time... Thanks for the help.

JokersMild85 started a new conversation Archived Video Series

If a video series has been archived, is it no longer viewable? I was working with the Laravel 5 fundamentals series and none of the videos will play now. Videos of other series play fine.

01 Nov
1 year ago

JokersMild85 left a reply on Laravel 5.5 Doesn't Recognize A Variable

Originally the controller code looked like this when I was receiving the undefined variable error:

class ArticlesController extends Controller {

public function show($id)
{     
    $article = Article::findOrFail($id);
    
    return view('articles.show', compact('article'));
}

public function edit($id)
{
    $article = Article::findOrFail($id);
    
    return view('articles.edit');
}

}

Once I added the compact('article) code to the Edit function the same way I applied it to the Show function, it worked fine.

Obvious mistake once you figure out what is causing the problem.

Thanks again guys.

JokersMild85 left a reply on Laravel 5.5 Doesn't Recognize A Variable

Never mind, I figured it out as I was posting my code. Thanks anyway. I'm sure I'll be posting more questions here in the near future.

JokersMild85 started a new conversation Laravel 5.5 Doesn't Recognize A Variable

So I'm working through the Laravel 5 Fundamentals series on episode 13 where I just created the Articles resource controller and added the Edit view... not exactly complicated stuff. However, I am receiving an error message saying that I have an undefined variable $article.

I most definitely defined the variable correctly and the code for the Edit function is basically identical to the Show function. There are no syntax errors, the function returns the articles.edit view fine but it just does not want to recognize the $article variable. Any suggestions what I am doing wrong?