jhutto

jhutto

Member Since 7 Months Ago

Experience Points 5,330
Experience
Level
Lessons Completed 41
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.

11 Jan
1 week ago

jhutto left a reply on Converting Mysql To Laravel Query

Perfect.. Thanks cemcminn... Yes.. I'm maintaining the database. I'm new to mysql.. so this is exactly what I needed.

jhutto left a reply on Converting Mysql To Laravel Query

I finally found some searches that lead me in the right direction.

$Registrations = DB::table('somascourseregistrations')
                ->select('somascourseregistrations.id', 'CourseID', 'TuitionType', 'FirstName', 'LastName',
                    DB::raw("(SELECT (ClassFee + HomeOfficeFee + MaterialsFee)                                
                                GROUP BY somascourseregistrations.id) as TotalTuition"),
                    DB::raw("(SELECT SUM(PaymentAmount) FROM somasstudentclasspayments
                                WHERE somasstudentclasspayments.RegistrationID = somascourseregistrations.id
                                GROUP BY somascourseregistrations.id) as TotalPayments"))
                ->join('students', 'students.id', '=', 'somascourseregistrations.StudentID')                
                ->where('CourseID', $courseid)
                ->orderby('LastName')
                ->get();

I'm still really new... But I will look at the stored procedures you are referring too. Can you give me some links to check out?

jhutto started a new conversation Converting Mysql To Laravel Query

I have a mysql query that I can not figure out how to translate into Laravel query in controller

The 355 will be a variable as soon as I can get this to run.

SELECT somascourseregistrations.id, `CourseID`, `StudentID`, `StatusID`, `TA`, `DropDate`, `TuitionType`, (`ClassFee`+`HomeOfficeFee`+`MaterialsFee`) AS TotalTuition,
(SELECT SUM(`PaymentAmount`) AS TotalPayments FROM `somasstudentclasspayments` WHERE somasstudentclasspayments.RegistrationID = somascourseregistrations.id) TotalPayments
FROM `somascourseregistrations` WHERE somascourseregistrations.CourseID = 355
10 Jan
1 week ago

jhutto started a new conversation Mysql Nested Query... How To Make It Work In Laravel Query

I've been trying to get this to work for quite awhile now and just need some help. I'm trying to write this query into a controller but can not figure out the format.

SELECT `CourseID`,`StudentID`, `ClassFee`,`HomeOfficeFee`,`MaterialsFee`, (`ClassFee`+`HomeOfficeFee`+`MaterialsFee`) AS TotalTuition, SUM(`PaymentAmount`)
FROM `somascourseregistrations`, `somasstudentclasspayments`
WHERE somascourseregistrations.id = somasstudentclasspayments.RegistrationID AND somascourseregistrations.id = $RegistrationID

Please help

23 Dec
4 weeks ago

jhutto left a reply on Can't Use The @ Sign In Javascript Code For Pulling Value

Thanks ahmeddabak, I finally resolved the issue with your help. Sorry for not explaining it better. This was a javascript issue, not laravel. It was an .ajax call that returned data and this issue was that way I tried to write the html table in javascript. All that I needed was to address the data correctly in javascript..

html += '<td>' + value['@id'] + '</td>';
html += '<td>' + value['firstName'] + ' ' + value['lastName'] + '</td>';

Thanks for you help. It did get me on the right track.

22 Dec
4 weeks ago

jhutto started a new conversation Can't Use The @ Sign In Javascript Code For Pulling Value

I'm working on a JavaScript code for an .ajax call to get data from an api application. Which is working ok but one of the values in the json data returned uses the @ as part of the index for the value. I can't seem to find a way to write the value.@id in a way that it will display in the view. Can any one explain to me why? I"m assuming the @ sign is a special character but I can't find anything that will give the special code value for the @ sign.

0:
@householdID: "1046330222"
@iCode: "7DFpn0vmmje4dA3bA9nNQQ=="
@id: "1075881761"
@imageURI: ""
@oldHouseholdID: ""
@oldID: ""
@uri: "https://milehi.staging.fellowshiponeapi.com/v1/People/1075881761"
addresses: {address: Array(2)}
firstName: "Jimmy"

When trying to display the data in a table, the @id comes back as not undefined

$.each(data, function(key, value) {
                        html += '<tr>';
                        html += '<td>' + [email protected] + '</td>';
                        html += '<td>' + value.firstName + ' ' + value.lastName + '</td>';

Thanks for any help on this.

20 Dec
1 month ago

jhutto left a reply on Add An Array Item To Collection Array In Controller

Thanks for your help guys... I probably didn't give you enough information. Sanpey... gave the idea I needed though, because I ended up just using the javascript code to add the values and display the total in the view. So, it's now working. Since it was using ajax call to the controller and returning json data, I parsed the json data to add the total.

totaltuitions = parseInt(value.ClassFee) + parseInt(value.MaterialsFee)+ parseInt(value.HomeOfficeFee);

I love the fact that when I need help, you guys respond so quickly to my questions. Even when I don't really know what I'm trying to do.

19 Dec
1 month ago

jhutto left a reply on Add An Array Item To Collection Array In Controller

Thanks for the quick reply. I'm using an ajax call on this item and need to return just one collection to a json. I then use that collection to layout the table in the view.

So, I need to add the item to the $Tuitions Collection. How do I add the TotalTuitions to the Tuitions collection?

jhutto started a new conversation Add An Array Item To Collection Array In Controller

I have three database fields that I need to add together and place in view. I'm using a ajax call to pull the data. I'm pulling the line of data from the database in the first collection that is created called Tuitions.

Then I"m adding the fields together in $TuitionTotal

Now I need to put the $TuitionTotal - Key 'TuitionTotal' and Value "140" back into the collection array[0] But I have not been able to find anything that works.

$Tuitions = Tuition::where('id', $id)->get();

$TuitionTotal = $Tuitions[0]->ClassFee + $Tuitions[0]->HomeOfficeFee + $Tuitions[0]->MaterialsFee ;
12 Dec
1 month ago

jhutto left a reply on Multiple Joins With Where's

Perfect... Sometimes we just get barrier in the code that we can't see the simple things. Like the wrong table and id. Thanks for your help.

jhutto started a new conversation Multiple Joins With Where's

I have a query that I can't get to work. It works if I take out the second join with instructors

$SemesterCourse = DB::table('coursesemester')
            ->join('somascourses', 'coursesemester.id', '=', 'somascourses.SemesterID')
            ->join('instructors', 'somascourses.SemesterID', '=', 'instructors.id')
            ->where([
                ['coursesemester.id', $semesterid],
                ['somascourses.id', $courseid],])
            ->get();

This mysql statement is working on the database

SELECT * FROM coursesemester
INNER JOIN somascourses ON coursesemester.id = somascourses.SemesterID
INNER JOIN instructors ON somascourses.Instructorid = instructors.id
WHERE coursesemester.id = 31 AND somascourses.id = 345

So, it seems to the the double Join that kills the query

11 Dec
1 month ago

jhutto left a reply on Adding Columns Of Row In Query Builder

That worded.. Thanks.

jhutto started a new conversation Adding Columns Of Row In Query Builder

I need to create a query to sum items in a row in query builder. Here is my current query in laravel

$SOMASRegistrations = \App\SOMASRegistration::where('CourseID', '=',  $course_id)
        ->join('somascourseregistrationstatus', 'somascourseregistrations.StatusID', '=', 'somascourseregistrationstatus.id')
        ->get();

I need to add three columns within the query and output as another column. Here is the mysql statement that works with the database

SELECT * , (ClassFee + HomeOfficeFee + MaterialsFee ) AS TotalFee FROM somascourseregistrations WHERE 1

I have tried this but it totals all the rows. I need the fields to be total only by each row.

$SOMASRegistrations = DB::table('somascourseregistrations') ->join('somascourseregistrationstatus', 'somascourseregistrations.StatusID', '=', 'somascourseregistrationstatus.id') ->select(DB::raw('sum(ClassFee+HomeOfficeFee+MaterialsFee) AS TotalFee')) ->where('CourseID', $course_id) ->get();

I couldn't find anything that talked about adding columns in a row in laravel Thanks for your help.

06 Dec
1 month ago

jhutto left a reply on Delete Confirmation In Form Button

Got it. Makes sense to me.

jhutto left a reply on Delete Confirmation In Form Button

If works fine. But I'm new to laravel and trying to learn the best way of doing things. So, that's why I posted this... Just wanted to make sure I wasn't missing something. Thanks for the response.

jhutto started a new conversation Delete Confirmation In Form Button

I have been working on a project and have a question about setting up a delete confirmation with the form. I can make it with a standard form

17 Oct
3 months ago

jhutto left a reply on Access Array Variable For Inserting Into Sql Table.

Thanks everyone for your help. This is the best for support.

jhutto left a reply on Access Array Variable For Inserting Into Sql Table.

$assistant['0']->NameCounter... Worked. Thanks for your help.

jhutto started a new conversation Access Array Variable For Inserting Into Sql Table.

I know this is a simple question and I should already know the answer but here it is....

I have an ajax call to a controller but I can't figure out how to access the array variable being created from a query call.

What am I doing wrong.. .And I know it's something simple.

This line is not getting inserted into the table. 'NameCounter' => $assistant->get('NameCounter'),

I have tried... 'NameCounter' => $assistant['NameCounter'], 'NameCounter' => $assistant['0']['NameCounter'],

 public function courseasstAjax($casstID, $courseID)
    {

             
        //Get NameCounter from Table of Course Assistants
        $assistant = DB::table('courseassistants')
        ->where('id', '=' , $casstID)
        ->get();
        
       
        //Create new record in SOMASCOURSEAssistants Table
        SOMASCourseAssistant::create([
             'ClassID' => $courseID,
              'NameCounter' => $assistant->get('NameCounter'),
          ]);
        
     
        
      return json_encode($assistant);

    

    }

I know the query is working because I can get it to return the array values in json....

[{…}]
0: {id: 7, NameCounter: 1649, FirstName: "Connie R", LastName: "Gabriel", Salutation: "Connie", …}
length: 1
__proto__: Array(0)
16 Oct
3 months ago

jhutto left a reply on Getting 500 (Internal Server Error) - When Sending Ajax Call To Controller

Thanks for the help... Cronix. I needed the logs to figure it out. It was an issue with the table name in the query that wasn't working correctly. It' working now. Thanks again.

jhutto started a new conversation Getting 500 (Internal Server Error) - When Sending Ajax Call To Controller

Getting 500 (Internal Server Error) - When sending ajax call to controller It's weird... .I'm using almost the exact same code in another page with not errors.

I have a drop down called courseassistants which has a list of names. I have a hidden input for the courseid.

 <label for="inputTA">Select Course Assistants to Add to Course: </label>
                            <input name="courseidnumber" id="courseidnumber" type="hidden" value="{{ $courseid  }}">
                            <select name="courseassistants" id="courseassistants" class="form-control">
                                <option value="">--- Select Assistant ---</option>
                                @foreach ($allassistants as $allassistant)
                                    <option value="{{ $allassistant->id }}">{{ $allassistant->FirstName }} {{ $allassistant->LastName }}</option>
                                @endforeach
                            </select>
                        </label>

Here's the ajax call:::

<script type="text/javascript">
$(document).ready(function() { 
    $('select[name="courseassistants"]').on('change', function() {
      var courseassistantID = $(this).val();
      var courseID = document.getElementById('courseidnumber').value;
      //var courseID = $('#courseidnumber').val();
      var html = '';
      $('#AssistantsTable').empty(); 
      console.log(courseassistantID, courseID);
      if(courseassistantID) {
                $.ajax({
                    url: '/courses/courseassistants/ajax/'+courseassistantID,
                    type: "GET",
                    dataType: "json",
                    success:function(data) {
                        
                        console.log(data);
                        html += '<table id="CoursesEdit" class="table table-striped table-bordered">';
                        html += '<thead><tr>';
                        html += '<th style="width: 10%"></th>';
                        html += '<th style="width: 30%">Course Name</th>';
                        html += '<th style="width: 20%">Instructor</th>';
                        html += '<th style="width: 10%">Day</th>';
                        html += '<th style="width: 10%">Time</th>';
                        html += '<th style="width: 10%"></th>';
                        html += '</tr></thead>';
                        
                        $.each(data, function(key, value) {
                            html += '<tr>';
                            html += '<td class="text-center"><a href="/courses/' + value.id + '/edit" id="btnRegistratios" class="btn btn-primary btn-lg" role="button">&nbsp; Registrations &nbsp;</a></td>';
                            html += '<td>' + value.ClassName + '</td>';
                            html += '<td>' + value.FirstName + ' '+ value.LastName + '</td>';
                            html += '<td>' + value.Day + '</td>';
                            html += '<td>' + value.Time + '</td>';
                            html += '<td class="text-center"><a href="/courses/' + value.SemesterID + '/' + value.course_id + '/edit" id="btnCourse" class="btn btn-primary btn-lg" role="button">&nbsp; Open &nbsp;</a></td>';
                           });
                        html += '</table>';
                        $('#coursesTable').append(html);
                       
                     
                    }
           
                });
                     
            }else{
                $('select[name="coursesTable"]').empty();
      }
      
  });
});
</script>

Here's the route:

Route::get('/courses/courseassistants/ajax/{casstID}',array('as'=>'courseasst.ajax','uses'=>'[email protected]'));

Controller function

 public function courseasstAjax($casstID, $ClassCourseID)
    {

        //dd($courseid);
        

        $coursesassistant = DB::table('coursesassistants')
        ->where('id', $casstID)
        ->get();
    

        return json_encode($coursesassistant);

     }

All I'm trying to do at this point is confirm everything is working, but I keep getting this error and no json data.

Please Help. Jimmy

29 Aug
4 months ago

jhutto left a reply on Creating Simple Dropdown From Database - Laravel Collective Form

That helped... Got some additional help and finalized it with this.... Thanks Croniz..

In Controller:

$instructors = DB::table('instructors')
            ->where('instructors.Viewable','=', 1)
            ->select(DB::raw('concat (FirstName," ",LastName) as FullName, id'));
            

$instructorOptions = array('' => 'Select Instructor') + $instructors->pluck('FullName', 'id')->toArray();

On View:

{{ Form::select('Instructors', $instructorOptions, null, ['class'=>'form-control']) }}

jhutto started a new conversation Creating Simple Dropdown From Database - Laravel Collective Form

I'm new to laravel and just trying to stay up to speed with the different versions. Using Laravel 5.6

I have created blade form and have been able to create my dropdown from the database,, but I keep running into forum questions showing selects using the Collective Form sytle. But I can't find anything in the documentation about the arguments for the {{ Form::Select ( arg1, arg2, arg3, arg4)}} ....... or how to create it from a database table.

So, I need help in writing this {{Form::Select }} statement that does the same thing as below.

Create Form ... Select looping through and creating the dropdown. Works good. Controller just pulls the list from database and passes it to the form as $instructors

<div class="form-group col-md-6">
                                                <label for="title">Instructor:</label>
                                                    <select name="Instructorid" id="Instructorid" class="form-control" style="width:350px;margin-left:50px;">
                                                        <option value="">--- Select Instuctor ---</option>
                                                        @foreach ($instructors as $instructor)
                                                            <option value="{{ $instructor->id }}">{{ $instructor->FirstName }} {{ $instructor->LastName }}"</option>">
                                                        @endforeach
                                                    </select>
                                                </label>
 </div>
``


How do I create the same loop in the {{ Form::select('Instructors', $instructors, ....) }} 
format?





17 Aug
5 months ago

jhutto started a new conversation Best Way To Process $request Data From Data Submitted On Form With Foreach Loop Table

What's the best way to take a table of data, show it on a form to edit using a foreach loop to create a table of input data. Then process it in the controller to update table in database.

To create the form I pull all the Tuition's from a db table that are associated with a Class ID.

$Tuitions = DB::table('tuitions')->where('ClassID','=', $coursesid)->get();

Then send it to the view.

Here's the form data creating a table of input in the view.

<div class="form-group col-md-12">
                                    <table id="Tuitions" class="table table-striped table-bordered">
                                            <thead><tr>
                                            <th style="width: 10%;text-align:center;">TuitionType</th>
                                            <th style="width: 30%;text-align:center;">TuitionDesc</th>
                                            <th style="width: 20%;text-align:center;">ClassFee</th>
                                            <th style="width: 20%;text-align:center;">HomeOfficeFee</th>
                                            <th style="width: 20%;text-align:center;">MaterialsFee</th>
                                            </tr></thead     
                                          
                                            @foreach ($Tuitions as $key=>$value)
                                            <tr>
                                                <input type="hidden" id="TuitionId" name="Tuitionid[]" value="{{ $value->id }}">
                                                <td><input type="text" id="TuitionType" name="TuitionType[]" style="text-align:center;"  value="{{ $value->TuitionType }}"></td>
                                                <td><input type="text" id="TuitionDesc" name="TuitionDesc[]"  style="width:350px" value="{{ $value->TuitionDesc }}"></td>
                                                <td><input type="text" id="ClassFee" name="ClassFee[]" style="text-align:center;" value="{{ $value->ClassFee }}"></td>
                                                <td><input type="text" id="HomeOfficeFee" name="HomeOfficeFee[]" style="text-align:center;" value="{{ $value->HomeOfficeFee }}"></td>
                                                <td><input type="text" id="MaterialsFee" name="MaterialsFee[]" style="text-align:center;" value="{{ $value->MaterialsFee }}"></td>
                                            @endforeach
                                              
                                              </label>
                                           
                                    </table>
                                </div>

Now here's the dd($request); The top portion of the request is data gathered in the same form that is class data. I have not problem pulling this information and updating it.

It's the data starting with Tuitionid... How do I extract this to update the tuitions table.

+request: ParameterBag {#64 ▼
    #parameters: array:15 [▼
      "_method" => "Patch"
      "_token" => "o6e8a4M2EnVsoUU4x87KbXtxFj1QXb9noiUjg3VG"
      "SemesterID" => "36"
      "Courseid" => "372"
      "ClassName" => "L&L Early Childhood"
      "instructor" => "10"
      "day" => "Thursday"
      "Time" => "6:30 PM"
      "Location" => "Vogt"
      "Tuitionid" => array:5 [▼
        0 => "4521"
        1 => "4522"
        2 => "4523"
        3 => "4524"
        4 => "4525"
      ]
      "TuitionType" => array:5 [▼
        0 => "SINGLE"
        1 => "COUPLE"
        2 => "S-STAFF"
        3 => "C-STAFF"
        4 => "GIFT"
      ]
      "TuitionDesc" => array:5 [▼
        0 => "Single"
        1 => "couple per person"
        2 => "single-staff"
        3 => "couple-staff"
        4 => "gift"
      ]
      "ClassFee" => array:5 [▼
        0 => "90.00"
        1 => "75.00"
        2 => "40.00"
        3 => "32.50"
        4 => "0.00"
      ]
      "HomeOfficeFee" => array:5 [▼
        0 => "0.00"
        1 => "0.00"
        2 => "0.00"
        3 => "0.00"
        4 => "0.00"
      ]
      "MaterialsFee" => array:5 [▼
        0 => "0.00"
        1 => "0.00"
        2 => "0.00"
        3 => "0.00"
        4 => "0.00"
      ]
    ]
  }

Anyone ?? Please help.

jhutto left a reply on Form Patch Submit Only Returning Last Record Of @foreach In Form

Thanks topvillas... That was it...

jhutto left a reply on Form Patch Submit Only Returning Last Record Of @foreach In Form

Sorry for the late response... Here's how I'm sending all the data to the form...

public function edittest($id, $coursesid)
    {
        
        

        $course = DB::table('somascourses')
            ->join('Instructors', 'somascourses.Instructorid', '=', 'Instructors.id')
            ->select('*','somascourses.id as course_id')
            ->where('somascourses.SemesterID','=','$id')
            ->orwhere('somascourses.id','=', $coursesid)
            ->get();
        
        //dd($course);

        $instructors = DB::table('instructors')->where('Viewable', '=', '1')->get();
        $semesterid = $id;
        $Courseid = $coursesid;

        $days = [
            'Sunday' => 'Sunday',
            'Monday' => 'Monday',
            'Tuesday' => 'Tuesday',
            'Wednesday' => 'Wednesday',
            'Thursday' => 'Thursday',
            'Friday' => 'Friday',
            'Saturday' => 'Saturday',
        ];

        $InstructorSelected = $course[0]->Instructorid;
       ($InstructorSelected);
       //dd($course);
       //dd($instructors);

       $Tuitions = DB::table('tuitions')->where('ClassID','=', $coursesid)->get();

       //dd($Tuitions);
      
       return view('courses.edittest', compact('course', 'instructors', 'semesterid', 'Courseid', 'days', 'InstructorSelected', 'Tuitions'));



    }

16 Aug
5 months ago

jhutto started a new conversation Form Patch Submit Only Returning Last Record Of @foreach In Form

I've create a edit form that is posting with patch method. I have a @foreach that creates the items in a table. When the form is submitted and I check the $request output it only returns the last entry from the @foreach loop. Can someone show me how to get all the values for each line item in the @foreach table

This is a simplified version of the form.

<!-- form user info -->
<div class="card card-outline-secondary">
<div class="card-header">
<h3 class="mb-0">Course Tuition</h3>
</div>
<div class="card-body">
 <form method="Post" action="/courses/{{ $Courseid }}" >
     @method('Patch')
     @csrf
                              
<div class="form-group col-md-12">
     <table id="Tuitions" class="table table-striped table-bordered">
               <thead><tr>
               <th style="width: 10%;text-align:center;">TuitionType</th>
               <th style="width: 30%;text-align:center;">TuitionDesc</th>
               <th style="width: 20%;text-align:center;">ClassFee</th>
               <th style="width: 20%;text-align:center;">HomeOfficeFee</th>
                <th style="width: 20%;text-align:center;">MaterialsFee</th>
                </tr></thead     
               @foreach ($Tuitions as $key=>$value)
                <tr>
        <td><input type="text" id="TuitionType" name="TuitionType" style="text-align:center;"  value="{{ $value->id }} {{ $value->TuitionType }}"></input></td>
            <td><input type="text" id="TuitionDesc" name="TuitionDesc"  style="width:350px" value="{{ $value->id }} {{ $value->TuitionDesc }}></td>
           <td><input type="text" id="ClassFee" name="ClassFee" style="text-align:center;" value="{{ $value->id }} {{ $value->ClassFee }}></td>
            <td><input type="text" id="HomeOfficeFee" name="HomeOfficeFee" style="text-align:center;" value="{{ $value->id }} {{ $value->HomeOfficeFee }}>/td>
            <td><input type="text" id="MaterialsFee" name="MaterialsFee" style="text-align:center;" value="{{ $value->id }} {{ $value->MaterialsFee }}></td>
                    @endforeach
              </table>
</div>
             <div class="form-row">
              <div class="form-group col-lg-9" Style="height:50px;margin-left: 25px;">
               <input type="submit" class="btn btn-primary btn-lg" value="Save Changes">
                  <a href="/registrations/courses/{{$course[0]->SemesterID}}" class="btn btn-secondary btn-lg" role="button">Cancel</a>
               </div>
</div>
</form>
                        
                        </div>
                    </div>

09 Aug
5 months ago

jhutto left a reply on Multiple Where Statements Not Working.

Sorry... It looks right but keep getting

syntax error, unexpected '}'

I've tried multiple variations.

jhutto started a new conversation Multiple Where Statements Not Working.

I'm passing multiple id's to a controller and trying to have it query the database. I have 3 tables that are linked in the query classsemester somascourses instructors

This mysql statement will retrieve the information from the database correctly. SELECT * FROM classsemester, somascourses, instructors WHERE classsemester.id = somascourses.SemesterID AND somascourses.Instructor_id = instructors.id AND classsemester.id = 2 AND somascourses.id = 2

Here's the function in the edit controller...

Since all the tables have a primary key of id.... I had to change the primary key for somascourses.id to course_id for it to show up in cc($course)l=; I need the to be able to put the starting table of classsemesters by the $id.. ID for that table and then pull the somascourses by a specific is using $courseid. Because I trying to pull a specific course from somascourses to edit.

 public function edit($id, $courseid)
    {
        
$course = DB::table('classsemester')
            ->join('somascourses', 'classsemester.id', '=', 'somascourses.SemesterID')    
            ->select('*','somascourses.id as course_id')
            ->join('Instructors', 'somascourses.Instructor_id', '=', 'Instructors.id')
            ->where('classsemester.id', '=', $id)
            ->orwhere('somascourses.SemesterID','=', $id)
            ->where('course_id', '=', $courseid)
            ->get();

}

How do I write this so, it will pull the same information as this mysql statement. SELECT * FROM classsemester, somascourses, instructors WHERE classsemester.id = somascourses.SemesterID AND somascourses.Instructor_id = instructors.id AND classsemester.id = 2 AND somascourses.id = 2

08 Aug
5 months ago

jhutto left a reply on Query That Has A Where Clause And With Clause.

Well .. I tried all of these but here's what worked..

$courses = \App\Course::where('SemesterID', $id)->join('Instructors', 'somascourses.Instructor_id', '=', 'Instructors.id')->get();

It returns all the fields from instructors table. I could not get any of the others to work and return the fields. I would love to be able to only return a few of the fields. Anyone????

07 Aug
5 months ago

jhutto left a reply on Query That Has A Where Clause And With Clause.

Got it.. Thanks... $courses = \App\Course::where('SemesterID', $id)->with('Instructor')->get(); This worked.

What about the other two questions???

jhutto started a new conversation Query That Has A Where Clause And With Clause.

I'm writing a ajax call to a controller with a function to return $courses I have two tables/Models... Courses and Instructors.

Instructor has...

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

Courses has...
public function Instructor()
    {
        return $this->belongsTo('App\Instructor');
    }

I have a query that's working but would like to know how to write it the eloquent way...

This works. $courses = \App\Course::where('SemesterID', $id)->join('Instructors', 'somascourses.Instructor_id', '=', 'Instructors.id')->get();

This gives me an error not understanding the ::with..... //$courses = \App\Course::where('SemesterID', $id)::with('Instructor')->get();

Sorry... A couple of more questions.

  1. Should I be writing these as functions in the Model ? Or is it ok in the controller?

  2. How do I bring over only specific fields from the instructors table in the query?

30 Jul
5 months ago

jhutto left a reply on Access Json Array Item Located At 3rd Level Down In The Array To Show In View

Thank you so much. Great feed back. The code for the API was written by someone else, and I haven't made any modifications yet.. But your suggestions were right down the alley of where I wanted to go with it. But there code did a bunch of the heavy lifting to make the api easy to access. Again.. Great feed back and I really appreciate your time in helping me.

jhutto left a reply on Access Json Array Item Located At 3rd Level Down In The Array To Show In View

Here's the controller code

    public function searchName(Request $request)
    {

       
        $settings = array(
             setting code for API
        );
    

        $f1 = new FellowshipOne($settings);
        
        if(($r = $f1->login()) === false){
        die("Failed to loign");
        }

                
        $r = $f1->searchPeople(array(//search attributes
            "searchFor"=>$request['lastname'],
        ));
    
        
        
        return view('F1.index', compact('r')); 
        

    }

jhutto left a reply on Access Json Array Item Located At 3rd Level Down In The Array To Show In View

That worked... Thanks.. Seems simple now. Is there a better way to bring the data over to the view.

jhutto left a reply on Access Json Array Item Located At 3rd Level Down In The Array To Show In View

Here's the code in the view. Sorry about the original post.. I'm new to posting for support.

<table id="EditTables" class="table table-striped table-bordered">
     <thead>
       <tr>
       <th style="width: 10%">Id</th>
        <th style="width: 30%">Name</th>
        <th style="width: 50%">Address</th>
        <th style="width: 10%">Status</th>

        <th style="width: 20%">Select</th>
       </tr>
     </thead>
@if($r && $r['results']['@count']>0)
  
 @foreach($r['results']['person'] as $person)
   <tr>
  
   <td>{{$person['@id']}}</td>
   <td>{{$person['firstName']}} {{$person['lastName']}}</td>
   <td>{{$person['addresses']['address']['address1']}} </td>
   <td>{{$person['status']['name']}}</td>
   <td class="text-center"><a href="#" id="btnSelect" class="btn btn-primary btn-lg" role="button">&nbsp; Select &nbsp;</a></td>
   </tr>
@endforeach
  
@endif

jhutto left a reply on Access Json Array Item Located At 3rd Level Down In The Array To Show In View

array:1 [▼
  "results" => array:5 [▼
    "@count" => "2"
    "@pageNumber" => "1"
    "@totalRecords" => "2"
    "@additionalPages" => "0"
    "person" => array:2 [▼
      0 => array:40 [▼
        "@id" => "1075735630"
        "@uri" => "https://milehi.staging.fellowshiponeapi.com/v1/People/1075735630"
        "@imageURI" => ""
        "@oldID" => ""
        "@iCode" => "wo4QwInnbVOPIAc+XntOPg=="
        "@householdID" => "1046185397"
        "@oldHouseholdID" => ""
        "title" => null
        "salutation" => null
        "prefix" => null
        "firstName" => "Jack"
        "lastName" => "Siegman"
        "suffix" => null
        "middleName" => null
        "goesByName" => null
        "formerName" => null
        "gender" => null
        "dateOfBirth" => null
        "maritalStatus" => null
        "householdMemberType" => array:3 [▶]
        "isAuthorized" => "true"
        "status" => array:6 [▶]
        "occupation" => array:4 [▶]
        "employer" => null
        "school" => array:3 [▶]
        "denomination" => array:3 [▶]
        "formerChurch" => null
        "barCode" => null
        "memberEnvelopeCode" => null
        "defaultTagComment" => null
        "weblink" => array:3 [▶]
        "solicit" => null
        "thank" => "true"
        "firstRecord" => "2016-02-04T09:06:17"
        "attributes" => null
        "addresses" => array:1 [▶]
        "communications" => null
        "lastMatchDate" => null
        "createdDate" => "2016-02-04T09:06:18"
        "lastUpdatedDate" => "2016-02-04T09:06:22"
      ]
      1 => array:40 [▶]
    ]
  ]
]

jhutto left a reply on Access Json Array Item Located At 3rd Level Down In The Array To Show In View

[code]

array:1 [▼ "results" => array:5 [▼ "@count" => "2" "@pageNumber" => "1" "@totalRecords" => "2" "@additionalPages" => "0" "person" => array:2 [▼ 0 => array:40 [▼ "@id" => "1075735630" "@uri" => "https://milehi.staging.fellowshiponeapi.com/v1/People/1075735630" "@imageURI" => "" "@oldID" => "" "@iCode" => "wo4QwInnbVOPIAc+XntOPg==" "@householdID" => "1046185397" "@oldHouseholdID" => "" "title" => null "salutation" => null "prefix" => null "firstName" => "Jack" "lastName" => "Siegman" "suffix" => null "middleName" => null "goesByName" => null "formerName" => null "gender" => null "dateOfBirth" => null "maritalStatus" => null "householdMemberType" => array:3 [▶] "isAuthorized" => "true" "status" => array:6 [▶] "occupation" => array:4 [▶] "employer" => null "school" => array:3 [▶] "denomination" => array:3 [▶] "formerChurch" => null "barCode" => null "memberEnvelopeCode" => null "defaultTagComment" => null "weblink" => array:3 [▶] "solicit" => null "thank" => "true" "firstRecord" => "2016-02-04T09:06:17" "attributes" => null "addresses" => array:1 [▶] "communications" => null "lastMatchDate" => null "createdDate" => "2016-02-04T09:06:18" "lastUpdatedDate" => "2016-02-04T09:06:22" ] 1 => array:40 [▶] ] ] ]

[/code]

jhutto left a reply on Access Json Array Item Located At 3rd Level Down In The Array To Show In View

Sure.. Sorry.. Let me try again.

... array:1 [▼ "results" => array:5 [▼ "@count" => "2" "@pageNumber" => "1" "@totalRecords" => "2" "@additionalPages" => "0" "person" => array:2 [▼ 0 => array:40 [▼ "@id" => "1075735630" "@uri" => "https://milehi.staging.fellowshiponeapi.com/v1/People/1075735630" "@imageURI" => "" "@oldID" => "" "@iCode" => "wo4QwInnbVOPIAc+XntOPg==" "@householdID" => "1046185397" "@oldHouseholdID" => "" "title" => null "salutation" => null "prefix" => null "firstName" => "Jack" "lastName" => "Siegman" "suffix" => null "middleName" => null "goesByName" => null "formerName" => null "gender" => null "dateOfBirth" => null "maritalStatus" => null "householdMemberType" => array:3 [▶] "isAuthorized" => "true" "status" => array:6 [▶] "occupation" => array:4 [▶] "employer" => null "school" => array:3 [▶] "denomination" => array:3 [▶] "formerChurch" => null "barCode" => null "memberEnvelopeCode" => null "defaultTagComment" => null "weblink" => array:3 [▶] "solicit" => null "thank" => "true" "firstRecord" => "2016-02-04T09:06:17" "attributes" => null "addresses" => array:1 [▶] "communications" => null "lastMatchDate" => null "createdDate" => "2016-02-04T09:06:18" "lastUpdatedDate" => "2016-02-04T09:06:22" ] 1 => array:40 [▶] ] ] ] ...

...

Id Name Address Status
    <th style="width: 20%">Select</th>
   </tr>
 </thead>

@if($r && $r['results']['@count']>0)

@foreach($r['results']['person'] as $person)

{{$person['@id']}} {{$person['firstName']}} {{$person['lastName']}} {{$person['addresses']['address']['address1']}} {{$person['status']['name']}}   Select   @endforeach

@endif ...

jhutto started a new conversation Access Json Array Item Located At 3rd Level Down In The Array To Show In View

I'm a newbie to laravel and I'm importing an Json Array from an API. The array has many levels of arrays.. (Below). I'm trying to get access to the Address in the array to show in my view. The array is a record of a person and the address buried in the array. I'm also including my code from page trying to load the item.

This line below gives me an Undefined index: address1...

{{$person['addresses']['address']['address1']}}

array:1 [▼ "results" => array:5 [▼ "@count" => "2" "@pageNumber" => "1" "@totalRecords" => "2" "@additionalPages" => "0" "person" => array:2 [▼ 0 => array:40 [▼ "@id" => "1075735630" "@uri" => "https://milehi.staging.fellowshiponeapi.com/v1/People/1075735630" "@imageURI" => "" "@oldID" => "" "@iCode" => "wo4QwInnbVOPIAc+XntOPg==" "@householdID" => "1046185397" "@oldHouseholdID" => "" "title" => null "salutation" => null "prefix" => null "firstName" => "Jack" "lastName" => "Siegman" "suffix" => null "middleName" => null "goesByName" => null "formerName" => null "gender" => null "dateOfBirth" => null "maritalStatus" => null "householdMemberType" => array:3 [▶] "isAuthorized" => "true" "status" => array:6 [▶] "occupation" => array:4 [▶] "employer" => null "school" => array:3 [▶] "denomination" => array:3 [▶] "formerChurch" => null "barCode" => null "memberEnvelopeCode" => null "defaultTagComment" => null "weblink" => array:3 [▶] "solicit" => null "thank" => "true" "firstRecord" => "2016-02-04T09:06:17" "attributes" => null "addresses" => array:1 [▼ "address" => array:1 [▼ 0 => array:22 [▼ "@id" => "1042967710" "@uri" => "https://milehi.staging.fellowshiponeapi.com/v1/Addresses/1042967710" "household" => array:2 [▶] "person" => array:2 [▶] "addressType" => array:3 [▶] "address1" => "413 Butterfield Trl" "address2" => null "address3" => null "city" => "Edmond" "postalCode" => "73003" "county" => null "country" => "US" "stProvince" => "OK" "carrierRoute" => null "deliveryPoint" => null "addressDate" => null "addressComment" => null "uspsVerified" => "false" "addressVerifiedDate" => null "lastVerificationAttemptDate" => null "createdDate" => "2016-02-04T09:06:37" "lastUpdatedDate" => "2016-02-04T09:06:38" ] ] ] "communications" => null "lastMatchDate" => null "createdDate" => "2016-02-04T09:06:18" "lastUpdatedDate" => "2016-02-04T09:06:22" ] 1 => array:40 [▶] ] ] ]

Id Name Address Status
    <th style="width: 20%">Select</th>
   </tr>
 </thead>

@if($r && $r['results']['@count']>0) @foreach($r['results']['person'] as $person)

{{$person['@id']}} {{$person['firstName']}} {{$person['lastName']}} {{$person['addresses']['address']['address1']}} {{$person['status']['name']}}   Select   @endforeach @endif
24 Jul
5 months ago

jhutto left a reply on Route Not Working.

thanks for the help... I'm going just use the suggested ... Route::resource('instructors', 'InstructorController')

Until I find another issue...

jhutto left a reply on Route Not Working.

That was the issue... I moved the create route up above the show route and it worked. This is new information to me... None of the videos that I have watched, explained the order. Thanks you so much.... Can you share with me the where I can find this information or just give me some pointers?

jhutto left a reply on Route Not Working.

Here's the routes page info... And the page just says in "Sorry ... Not found. No errors. Auth::routes();

Route::get('/', function () { return view('welcome'); });

Route::get('/instructors', '[email protected]');

Route::get('/instructors/{instructor}', '[email protected]');

Route::get('/instructor/create', '[email protected]');

jhutto left a reply on Route Not Working.

Sorry... It didn't include all the information on that last post....

Web.php file

jhutto left a reply on Route Not Working.

So, I have cleared the cache and cleaned down my web.php to a minimum

jhutto started a new conversation Route Not Working.

I'm running Laravel 5.6... Having trouble with one specific route. It just won't work. I have this route in my web.php Route::get('/instructors/create', '[email protected]'); Here's the function in the InstructorsController.php public function create() { //

    return view('instructors.create');



}

But the web page will not load.

If I simply change the route to Route::get('/instructor/create', '[email protected]'); Just taking the "s" off the end of instructor(s) the page loads. This makes no sense to me. can someone explain why?