JokersMild85

Experience

1,930

0 Best Reply Awards

  • Member Since 3 Weeks Ago
  • 15 Lessons Completed
  • 0 Favorites

14th November, 2017

JokersMild85 left a reply on Undefined Offset Error • 1 week ago

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 • 1 week ago

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 • 1 week ago

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>";
    } 

}

11th November, 2017

JokersMild85 started a new conversation Problem Retrieving Values From Imported Array • 1 week ago

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.

10th November, 2017

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

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;
}

8th November, 2017

JokersMild85 left a reply on Foreach Loop In HTML Form Builder Form • 1 week ago

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 • 1 week ago

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 • 1 week ago

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.

7th November, 2017

JokersMild85 left a reply on Set Logout Route In Laravel 5.5 • 2 weeks ago

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.

6th November, 2017

JokersMild85 started a new conversation Set Logout Route In Laravel 5.5 • 2 weeks ago

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 • 2 weeks ago

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 • 2 weeks ago

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.

1st November, 2017

JokersMild85 left a reply on Laravel 5.5 Doesn't Recognize A Variable • 2 weeks ago

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 • 2 weeks ago

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 • 2 weeks ago

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?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.