Methmi

Methmi

Member Since 3 Months Ago

Experience Points
1,680
Total
Experience

3,320 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
6
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 1
1,680 XP
Aug
11
1 month ago
Activity icon

Started a new Conversation Retrieve Data Fro Database To An Array

This is my function

public function update(Request $request,$projects)
    {
         $projects = Projects::findOrFail($projects);
         $projectmachines = Projectmachines::all();
         $projects->p_gid = $request->p_gid;
         $projects->p_name = $request->p_name;
         $projects->p_adate = $request->p_adate;
         $projects->p_company = $request->p_company;
         $projects->p_person = $request->p_person;
         $projects->p_mobile = $request->p_mobile;
         $projects->p_address1 = $request->p_address1;
         $projects->p_address2= $request->p_address2;
         $projects->p_address3 = $request->p_address3;
         $projects->p_notes = $request->p_notes;
         $projects->p_status = $request->p_status;
        $projects->save();

        pstatus::create([
        'ps_pid' => $projects->p_id,
        'p_status' => $request->p_status,
        'p_sreason' => $request->p_sreason,
    ]);
    if($request->p_status == "Completed" || $request->p_status == "Abandoned")
        {

            $pm = DB::table('projectmachines')
            ->find('projects.p_gid', $request->p_gid)
            ->select('projectmachines.pm_mid')
            ->get()
            ->toArray();
           

    foreach($pm as $a) {

       $mstatus = DB::table('machines')
              ->findOrFail($a)
              ->update(['machines.m_status' => "Assigned"]);

             mstatus::create([
        'ms_mid' => [$a],
        'm_status' => $request->m_status,
        'm_sreason' => $request->m_sreason,
    ]);  
    
        }

         dd($pm);
    }
    
       return redirect()->route('dashboard.projects.index');
   
    }

This gives the error

(1/1) ErrorException Argument 1 passed to Illuminate\Database\Grammar::columnize() must be of the type array, string given, called in C:\xampp\htdocs\MachineCenter\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php on line 131 and defined

How can I solve this

Activity icon

Replied to Update Two Tables With If Condition

But still did not work

Activity icon

Replied to Update Two Tables With If Condition

Cannot you help to solve this

Activity icon

Replied to Data Cannot Be Shown With Wherebetween

I tried this but still the PDF does not show any data in the report generated.But when I remove wherebetween it shows all the data in the table

Activity icon

Replied to Data Cannot Be Shown With Wherebetween

Yes the date format does not change

Activity icon

Replied to Data Cannot Be Shown With Wherebetween

It is null,null

Activity icon

Started a new Conversation Update Two Tables With If Condition

I need to update machine table status and add a row to mstatus table if the status of the project becomes completed or abandoned. This does not give any error but does not update the machine table and create a row in mstatus table. How can I solve this?

public function update(Request $request,$projects)
    {
         $projects = Projects::findOrFail($projects);
         $projectmachines = Projectmachines::all();
         $projects->p_gid = $request->p_gid;
         $projects->p_name = $request->p_name;
         $projects->p_adate = $request->p_adate;
         $projects->p_company = $request->p_company;
         $projects->p_person = $request->p_person;
         $projects->p_mobile = $request->p_mobile;
         $projects->p_address1 = $request->p_address1;
         $projects->p_address2= $request->p_address2;
         $projects->p_address3 = $request->p_address3;
         $projects->p_notes = $request->p_notes;
         $projects->p_status = $request->p_status;
        $projects->save();

        pstatus::create([
        'ps_pid' => $projects->p_id,
        'p_status' => $request->p_status,
        'p_sreason' => $request->p_sreason,
    ]);
    if($request->p_status == "Completed"|"Abandoned")
        {

            $pm = DB::table('projectmachines')
            ->where('projectmachines.pm_pid', $projects)
            ->select('projectmachines.pm_mid')
            ->get();

           

    foreach($pm as $a) {

       $mstatus = DB::table('machines')
              ->findOrFail($a)
              ->update(['machines.m_status' => "Assigned"]);

             mstatus::create([
        'ms_mid' => [$a],
        'm_status' => $request->m_status,
        'm_sreason' => $request->m_sreason,
    ]);  
   
    
        }
    }
    
       return redirect()->route('dashboard.projects.index');
   
    }
Aug
09
1 month ago
Activity icon

Replied to Data Cannot Be Shown With Wherebetween

It is just date(drc_date)

Activity icon

Started a new Conversation Data Cannot Be Shown With Wherebetween

This is my controller

 $machines = Machines::find($id);
       $sdate = $request->get('sdate');
        $edate = $request->get('edate');

        $dailyrunningcharts = dailyrunningcharts::where('drc_mid',$id)
        ->whereBetween('drc_date', [$sdate, $edate])
        ->get();

When I give this, It does not show any results, just empty table and then remove the wherebetween clause it shows the alldata in the table. This code is used in search function

This is my blade

 <form action="{{ route('edaterange',$employees->e_id)}}" method="get">
        <div class="form-row">

        <div class="col">
          <div class="form-group row">
            &nbsp
         <label >From :</label>
         <div class="col-sm-8">
         <input class="form-control" type="Date" name="sdate" value="{{$sdate}}">
       </div>
     </div>
        </div>
        <div class="col">
          <div class="form-group row">
         <label >To :</label>
         <div class="col-sm-8">
        <input class="form-control" type="Date" name="edate" value="{{$edate}}">
      </div>
        </div>
      </div>
       <button class="btn btn-success" style="height: 40px;" >Filter</button>
       &nbsp &nbsp
        <a href="{{ route('e_overview_report',$employees->e_id)}}" type="submit" class="btn btn-primary" style="height: 40px;">Refresh</a>
        </div>
      </form>

How to get retrieve data with wherebetween.

Aug
08
1 month ago
Activity icon

Started a new Conversation Create PDF On Searched View

This is my controller to the search, searched view and pdf generation

 public function mdaterange(Request $request,$id)
    {
         $machines = Machines::find($id);
       $sdate = $request->get('sdate');
        $edate = $request->get('edate');

        $dailyrunningcharts = dailyrunningcharts::where('drc_mid',$id)
        ->whereBetween('drc_date', [$sdate, $edate])
        ->get();

             $ename = DB::table('employees')
            ->where('dailyrunningcharts.drc_moperator', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_moperator', '=', 'employees.e_id')
            ->select('employees.e_sname')
            ->get();

             $pname = DB::table('projects')
            ->where('dailyrunningcharts.drc_pid', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_pid', '=', 'projects.p_id')
            ->select('projects.p_name')
            ->get();

        return view('dashboard.machines.m_overview_report', compact('machines','dailyrunningcharts','ename','pname','sdate','edate'))->with('drc_mid',$id);
               
    }
 public function m_overview_report(Request $request,$id)
    {
          $machines = Machines::find($id);
       $sdate = $request->get('sdate');
        $edate = $request->get('edate');

        $dailyrunningcharts = dailyrunningcharts::where('drc_mid',$id)->get();
       

             $ename = DB::table('employees')
            ->where('dailyrunningcharts.drc_moperator', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_moperator', '=', 'employees.e_id')
            ->select('employees.e_sname')
            ->get();

             $pname = DB::table('projects')
            ->where('dailyrunningcharts.drc_pid', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_pid', '=', 'projects.p_id')
            ->select('projects.p_name')
            ->get();

        return view('dashboard.machines.m_overview_report', compact('machines','dailyrunningcharts','ename','pname','sdate','edate'))->with('drc_mid',$id);
               
    }
 public function mor_pdf(Request $request,$id)
    {
          $machines = Machines::find($id);
       $sdate = $request->get('sdate');
        $edate = $request->get('edate');

         $dailyrunningcharts = dailyrunningcharts::where('drc_mid',$id)->get();

         $ename = DB::table('employees')
            ->where('dailyrunningcharts.drc_moperator', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_moperator', '=', 'employees.e_id')
            ->select('employees.e_sname')
            ->get();

             $pname = DB::table('projects')
            ->where('dailyrunningcharts.drc_pid', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_pid', '=', 'projects.p_id')
            ->select('projects.p_name')
            ->get();
        

            $pdf = PDF::loadView('dashboard.machines.mor_pdf',compact('machines','dailyrunningcharts','ename','pname','sdate','edate'));
        return $pdf->stream('dashboard.machines.mor_pdf.pdf');
        
    }

This is the blade where it can search

 <div class="card" style="height: 80px;" >
      <div class="card-body">
        <div class="row">
          <div class="col-8">

             <form action="{{ route('mdaterange',$machines->m_id)}}" method="get">
        <div class="form-row">

        <div class="col">
          <div class="form-group row">
            &nbsp
         <label >From :</label>
         <div class="col-sm-8">
         <input class="form-control" type="Date" name="sdate" value="{{$sdate}}">
       </div>
     </div>
        </div>
        <div class="col">
          <div class="form-group row">
         <label >To :</label>
         <div class="col-sm-8">
        <input class="form-control" type="Date" name="edate" value="{{$edate}}">
      </div>
        </div>
      </div>
       <button class="btn btn-success" style="height: 40px;" >Filter</button>
       &nbsp &nbsp
        <a href="{{ route('m_overview_report',$machines->m_id)}}" type="submit" class="btn btn-primary" style="height: 40px;">Refresh</a>
        </div>
      </form>
  
          </div>
          <div class="col">
              <a href="{{ route('mor_pdf',$machines->m_id)}}" type="submit" class="btn btn-info float-right" >Save As PDF </a>
          </div>
        </div>
    </div>
    </div>

  <div class="card " >

    <div class="card-header">
    <h5 class="card-title">
      
      <div  class="form-inline">
    <label>Machine ID :</label>
    &nbsp &nbsp
    <label>{{ $machines->m_gid }}</label>
    </div>

    <div  class="form-inline">
    <label>Machine Type :</label>
    &nbsp &nbsp
    <label>{{ $machines->m_type }}</label>
    </div>

        </h5>
  </div>

  <div class="card-body">
  <table class="table table-striped">

        <thead class="thead-dark">
        <tr>
          <th scope="col">Date</th>
          <th scope="col">Project</th>
          <th scope="col">Machine Operator</th>
          <th scope="col">Hours</th>
          <th scope="col">Work Type</th>
          <th scope="col">Notes</th>
          <th scope="col"></th>
        </tr>
      </thead>
      <tbody>
      
        @foreach($pname as $d)
          @foreach($ename as $e)
         @foreach($dailyrunningcharts as $c)
        <tr>
          <td>{{ $c->drc_date }}</td> 
          <td>{{ $d->p_name }}</td>
          <td>{{ $e->e_sname }}</td>
          <td>{{ $c->drc_hours }} hrs</td>
          <td>{{ $c->drc_worktype }}</td>
           <td>{{ $c->drc_notes }}</td>
           <td>
           <div class="btn-group">
            <a href="#" class="btn btn-info"><i class="fas fa-edit"></i></a>
            
            </div>
            </td>
        </tr>
        @endforeach
        @break
         @endforeach
         @break
          @endforeach 

       
       </tbody>
    </table>    
</div>


 </div>

This is the blade for pdf generation

<h4>

    <div  class="form-inline">
    <label>Machine ID :</label>
    <label>{{ $machines->m_gid }}</label>
  </div>

    <div  class="form-inline">
    <label>Machine Type :</label>
    <label>{{ $machines->m_type }}</label>
    </div>

    <div  class="form-inline">
    <label>Time Duration :</label>
    <label>From</label>
    <label>{{ $sdate }}</label>
    <label>To</label>
    <label>{{ $edate }}</label>
    </div>

    </h4>

    <form action="{{ route('mdaterange',$machines->m_id)}}" method="get">
        <div class="form-row">

        <div class="col">
          <div class="form-group row">
            &nbsp
         <label >From :</label>
         <div class="col-sm-8">
         <input class="form-control" type="Date" name="sdate" value="{{$sdate}}">
       </div>
     </div>
        </div>
        <div class="col">
          <div class="form-group row">
         <label >To :</label>
         <div class="col-sm-8">
        <input class="form-control" type="Date" name="edate" value="{{$edate}}">
      </div>
        </div>
      </div>
       <button class="btn btn-success" style="height: 40px;" >Filter</button>
       &nbsp &nbsp
        <a href="{{ route('m_overview_report',$machines->m_id)}}" type="submit" class="btn btn-primary" style="height: 40px;">Refresh</a>
        </div>
      </form>
  

  
   <table>

        <thead>
        <tr>
          <th scope="col">Date</th>
          <th scope="col">Project</th>
          <th scope="col">Machine Operator</th>
          <th scope="col">Hours</th>
          <th scope="col">Work Type</th>
          <th scope="col">Notes</th>
          
        </tr>
    </thead>
    <tbody>
        @foreach($pname as $d)
          @foreach($ename as $e)
         @foreach($dailyrunningcharts as $c)
        <tr>
          <td>{{ $c->drc_date }}</td> 
          <td>{{ $d->p_name }}</td>
          <td>{{ $e->e_sname }}</td>
          <td>{{ $c->drc_hours }}</td>
          <td>{{ $c->drc_worktype }}</td>
           <td>{{ $c->drc_notes }}</td>
        </tr>
        @endforeach
        @break
         @endforeach
         @break
          @endforeach 
        </tbody>
    </table>


How can I view the searched results in my pdf

Activity icon

Started a new Conversation SQL Error

This is my Controller

 public function pdaterange(Request $request,$id)
    {

        $projects = Projects::find($id);
        
        $sdate = $request->get('sdate');
        $edate = $request->get('edate');

        $dailyrunningcharts = dailyrunningcharts::select('drc_pid',$id)
        ->whereBetween('drc_date', [$sdate, $edate])
        ->get();

             $ename = DB::table('employees')
            ->where('dailyrunningcharts.drc_moperator', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_moperator', '=', 'employees.e_id')
            ->select('employees.e_sname')
            ->get();

              $mname = DB::table('machines')
            ->where('dailyrunningcharts.drc_mid', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_mid', '=', 'machines.m_id')
            ->select('machines.m_type')
            ->get();

        return view('dashboard.projects.p_overview_report', compact('projects','dailyrunningcharts','ename','mname'))->with('drc_pid',$id);
               
    }

this is my form

<form action="{{ route('pdaterange',$projects->p_id)}}" method="get">
        <div class="form-row">

        <div class="col">
          <div class="form-group row">
            &nbsp
         <label >From :</label>
         <div class="col-sm-8">
         <input class="form-control" type="Date" name="sdate">
       </div>
     </div>
        </div>
        <div class="col">
          <div class="form-group row">
         <label >To :</label>
         <div class="col-sm-8">
        <input class="form-control" type="Date" name="edate">
      </div>
        </div>
      </div>
       <button class="btn btn-success" style="height: 40px;" >Filter</button>
       &nbsp &nbsp
      <button class="btn btn-secondary" style="height: 40px;" >Refreash</button>
        </div>
      </form>

This gives the error (2/2) QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column '1' in 'field list' (SQL: select drc_pid, 1 from dailyrunningcharts where drc_date between 2020-08-15 and 2020-08-22)

How can I solve this?

Aug
07
1 month ago
Activity icon

Replied to Update In Laravel

(2/2) ErrorException
Trying to get property of non-object (View: C:\xampp\htdocs\MachineCenter\resources\views\dashboard\projects\view_projects.blade.php)

It gives this error

Aug
06
1 month ago
Activity icon

Started a new Conversation Update In Laravel

I need to update the data in pop up. this is my controller

public function show($id)
    {
       $projects = Projects::findOrFail($id);
       $projectmachines = projectmachines::where('pm_pid',$id)->get();

              $mname = DB::table('machines')
            ->where('projectmachines.pm_pid', $id)
            ->join('projectmachines', 'projectmachines.pm_mid', '=', 'machines.m_id')
            ->select('machines.m_type','machines.m_id')
            ->get();

            $count = 1;

        return view('dashboard.projects.view_projects', compact('projects','projectmachines','mname','count'));
    }
 public function update(Request $request,$projectmachines)
    {

        $projectmachines = Projectmachines::findOrFail($projectmachines->id);
        $projectmachines->pm_date = $request->pm_date;
        $projectmachines->pm_mid = $request->pm_mid;
        $projectmachines->pm_duration = $request->pm_duration;
        $projectmachines->pm_location = $request->pm_location;
        $projectmachines->pm_mincharge = $request->pm_mincharge;
        $projectmachines->pm_rental = $request->pm_rental;
        $projectmachines->save();
        return redirect()->route('dashboard.projects.index');
    }

This is my blade

<div class="card-header">
                <h3 class="card-title"></h3>
              </div>

              <form role="form" method="POST" action="{{route('dashboard.projectmachines.update', $projectmachines->id)}}">

              <!-- form body -->
              <div class="card-body">
                
                 <input type="hidden" name="_method" value="PUT"  >
                 <input type="hidden" name="_token" value="{{csrf_token()}}">

                <input type="hidden" name="pm_pid" >

                 <input type="hidden" name="pm_mid">

This is the button to pop up

<button type="button" class="btn btn-info" data-id="{{ $c->id }}" onCl data-toggle="modal" data-target="#exampleModal"><i class="fas fa-edit"></i></button>
 <script>
      $(document).ready(function () {
       // code to read selected table row cell data (values).
       var id = button.data('id')

       modal.find('.modal-body #id').val(id);

       $("#myTable").on("click", ".btn", function () {

        var id = button.data('id')

       modal.find('.modal-body #id').val(id);

          // get the current row
          var currentRow = $(this).closest("tr");

          var col1 = currentRow.find("td:eq(0)").text(); // get current row 1st TD value
          var col2 = currentRow.find("td:eq(1)").text(); // get current row 2nd TD
          var col3 = currentRow.find("td:eq(2)").text(); // get current row 3rd TD
          var col4 = currentRow.find("td:eq(3)").text(); // get current row 4th TD
          var col5 = currentRow.find("td:eq(4)").text(); // get current row 5th TD
          var col6 = currentRow.find("td:eq(5)").text(); // get current row th TD
          var data = col1 + "\n" + col2 + "\n" + col3 + "\n" + col4 + "\n" + col5 + "\n" + col5;

          $("#pm_date").val(col1);
          $("#pm_mid").val(col2);
          $("#pm_duration").val(col3);
          $("#pm_location").val(col4);
          $("#pm_mincharge").val(col5);
          $("#pm_rental").val(col6);

          
          // alert(data);
        });
      
      });
    </script>

But this gives the error (2/2) ErrorException Property [id] does not exist on this collection instance. (View: C:\xampp\htdocs\MachineCenter\resources\views\dashboard\projects\view_projects.blade.php)

Jul
15
2 months ago
Activity icon

Replied to Pass Data To Modal Using Jquery

I have done it already

 <tbody>
                        @foreach($mname as $d)
                        @foreach($projectmachines as $c)
                        <tr>
                          <td>{{ $c->pm_date }}</td>
                          <td>{{ $d->m_type }}</td>
                          <td>{{ $c->pm_duration }} months</td>
                          <td>{{ $c->pm_location }}</td>
                          <td>{{ $c->pm_mincharge }} hrs</td>
                          <td>{{ $c->pm_rental }}</td>
                          <td>

                                                        
                        <div class="btn-group btn-group-sm">

                        <a href="" id="{{ $c->id }}" type="button" data-target="#exampleModal" data-toggle="modal" class="btn btn-info btn-sm"><i class="fas fa-edit"></i></a>
                        <a href="#" class="btn btn-danger"><i class="fas fa-trash"></i></a>
                      </div>

                          </td>
                        </tr>
                        @endforeach
                        @break
                        @endforeach 
                        </tbody>

the problem is in

<form role="form" method="POST" action="{{ route('dashboard.projectmachines.update', $projectmachines->id)}}">

For this, it is needed to pass the id before.So how can I do that

Activity icon

Replied to Pass Data To Modal Using Jquery

It comes because of this action

  <form role="form" method="POST" action="{{ route('dashboard.projectmachines.update', $projectmachines->id)}}">

for this action, I should pass the id in the click event. I do not know how to da that

Activity icon

Started a new Conversation Pass Data To Modal Using Jquery

I need to do my edit function in the modal pop-up.

This is the button that makes modal pop-up

<a href="" id="{{ $c->id }}" type="button" data-target="#exampleModal" data-toggle="modal" class="btn btn-info btn-sm"><i class="fas fa-edit"></i></a>

This is the jquery for that

 <script type="text/javascript">
          
         $('#exampleModal').on('shown.bs.modal', function () {
        $('#myInput').trigger('focus')
      })

  </script>

It gives the error Property [id] does not exist on this collection instance. I think the problem is with my jquery. How can I pass the projectmachine ID to the edit form using the jquery

This is the form tag and that is why it gives the error ```

``` For this, I need to pass id before. How can I pass it
Jul
02
2 months ago
Activity icon

Replied to Adding Data To Two Tables

Thank you bobbybouwmann:)

Jul
01
2 months ago
Activity icon

Started a new Conversation Adding Data To Two Tables

Using the add machine table I need to add data to the machine table as well mstatus table with the machine id date and status called active. For that, this is my create function in machine controller

 public function store(Request $request,Machines $machines )
    {

        $machines->m_gid = $request->m_gid;
        $machines->m_type = $request->m_type;
        $machines->m_enumber = $request->m_enumber;
        $machines->m_idate = $request->m_idate;
        $machines->m_seller = $request->m_seller;
        $machines->m_smobile = $request->m_smobile;
        $machines->m_saddress1 = $request->m_saddress1;
        $machines->m_saddress2 = $request->m_saddress2;
        $machines->m_saddress3 = $request->m_saddress3;
        $machines->m_notes = $request->m_notes;
        $machines->m_status = $request->m_status;
        $machines->save();
        return redirect()->route('dashboard.machines.index');
         
    }

How can I do that

Jun
16
3 months ago
Activity icon

Replied to Edit And Create In The Same Form

I have referred this before, but there it uses if-else but in my case I need both happen simultaneously. Is there a way to do that?

Activity icon

Started a new Conversation Edit And Create In The Same Form

I need to add data to a table called projectmachines while the selected machine in the form by the details of the machine table should be updated as it is assigned in the status column. How can I do that?

Activity icon

Replied to What Is The Best Way To Use Same Form For Create And Edit Blade Template In Laravel 6?

Cannot I do both updates and create in two different tables using a single form(I need to update the state when I select one particular data from the dropdown list)

Jun
08
3 months ago
Activity icon

Replied to Foreach Loop Is Not Working

id is an integer

public function machineindex()
    {
       
        $projectmachines = projectmachines::where('pm_pid')->get();
      
        return view('dashboard.dailyrunningcharts.drcpmachinesview', compact('projectmachines'));
    }

Even for this nothing is displayed. I am new to laravel, can you please help

Activity icon

Replied to Foreach Loop Is Not Working

Even for this nothing is displayed. not even an error

Activity icon

Replied to Foreach Loop Is Not Working

It just shows the heading but not the content of foreach loop. Even there is no any error.

I have assigned project id as the pm_pid and machine id as pm_mid in the projectmachines table. Here I need is showing the machines of a particular project.

 <a href="{{ route('machineindex', $c->p_id)}}" type="submit" class="btn btn-secondary">Go to machines of the Project</a>

By this project is selected from the project table. From above controller I need to display the machines of the project that is in projectmachines table.

Jun
07
3 months ago
Activity icon

Replied to (1/1) NotFoundHttpException In RouteCollection.php Line 179

 public function machineindex(projects $id)
    {
    
       $projectmachines = projectmachines::where('pm_pid',$id)->get();
        return view('dashboard.dailyrunningcharts.drcpmachinesview', compact('projectmachines'));
    }

This worked but does not give any output for foreach loop

and Form is not wrapped

Activity icon

Started a new Conversation Foreach Loop Is Not Working

@foreach($projectmachines as $c)
		<div class="card w-75 text-white bg-info text-right" >
	    <div class="card-body">
        <h5 class="card-title">{{ $c->pm_mid }}</h5>
        <a href="{{ route('dashboard.dailyrunningcharts.create')}}" type="submit" class="btn btn-secondary">Go to machines of the Project</a>
 		</div>
		</div>
		@endforeach

Controller is this

public function machineindex(projects $id)
    {
    
       $projectmachines = projectmachines::where('pm_pid',$id)->get();
        return view('dashboard.dailyrunningcharts.drcpmachinesview', compact('projectmachines'));
    }

foreach loop is not working.What can I do for that

Activity icon

Replied to (1/1) NotFoundHttpException In RouteCollection.php Line 179

		@foreach($projects as $c)
		<div class="card w-75 text-white bg-info text-right" >
	    <div class="card-body">
        <h5 class="card-title">{{ $c->p_name }}</h5>
        <a href="{{ route('machineindex', $c->p_id)}}" type="submit" class="btn btn-secondary">Go to machines of the Project</a>
 		</div>
		</div>
		@endforeach

Activity icon

Started a new Conversation (1/1) NotFoundHttpException In RouteCollection.php Line 179

Route::get('/dashboard/machineindex/{id}', 'Dashboard\[email protected]')->name('machineindex');
public function machineindex($id)
    {
        $projects = Projects::findOrFail($id);
       $projectmachines = projectmachines::where('pm_pid',$id)->get();
        return view('dashboard.projects.drcpmachinesview', compact('projects','projectmachines'));
    }
<a href="{{ route('machineindex', $c->p_id)}}" type="submit" class="btn btn-secondary">Go to machines of the Project</a>

and gives the above error.What can I do

Activity icon

Started a new Conversation Compare The Equality Of The Data Columns In Two Tables

I need to check whether the project_id of the project table is equal to the pm_pid in projectmacchine table to generate some output. How can I do that.

I need to get this in another controller blade not in both projects and projectmachines

public function machineindex()
    {
    
         $projects = projects::all();
         $projectmachines = ProjectMachines::all();
         return view('dashboard.dailyrunningcharts.drcpmachinesview', compact('projects','projectmachines'));
          
    }

Above function is in the another controller called DailyRunningCharts

Jun
06
3 months ago
Activity icon

Started a new Conversation Add New Function To Resource Controller

I need to add mindex function to resource controller and controller is inside the dashboard folder

Route::get('/dashboard/mindex', 'Dashboard\[email protected]')->name('mindex');

this gives the error Route [dashboard.dailyrunningcharts.mindex] not defined.

<a href="{{ route('dashboard.dailyrunningcharts.mindex')}}" type="submit" class="btn btn-secondary">Project</a>
Activity icon

Started a new Conversation Property [p_id] Does Not Exist On This Collection Instance.

I need to get a particular project ID to projectmachines table.

This is the code in project blade

<a href="{{route('dashboard.projectmachines.create', $c->p_id)}}" class="btn btn-info" >Add Machines</a>

and this leads to the projectmachines form

 <div class="form-group">
    <input type="hidden" name="pm_pid"  value="{{($projects->p_id)}}>
    </div>

and this is my create projectmachines controller

  public function create()
    {
         $machines = machines::all();
         $projects = projects::all();
        
        return view('dashboard.projects.add_machinestoproject', compact('machines','projects'));
    }

public function store(Request $request, Projectmachines $projectmachines)
    {
        $projectmachines->pm_pid = $request->pm_pid;
        $projectmachines->pm_date = $request->pm_date;
        $projectmachines->pm_mid = $request->pm_mid;
        $projectmachines->pm_location = $request->pm_location;
        $projectmachines->pm_runit = $request->pm_runit;
        $projectmachines->pm_mincharge = $request->pm_mincharge;
        $projectmachines->pm_rental = $request->pm_rental;
        $projectmachines->save();
         
    } 

This gives the error Property [p_id] does not exist on this collection instance.

How can I give the project id to the projectmachines table

Jun
05
3 months ago
Activity icon

Replied to Non-object Property

Thank you very much. It solves the problem

Activity icon

Replied to Non-object Property

I am new to the laravel and this is my first project. project id is a foreign key of projectmachines table. When I gave as above it gives the error Trying to get property of non-object (View: C:\xampp\htdocs\MachineCenter\resources\views\dashboard\projects\view_projects.blade.php). How can I solve this

Activity icon

Replied to Non-object Property

I need to access two models data through this controller. Actually, it looks like this

public function show($id) { $projects = Projects::findOrFail($id); return view('dashboard.projects.view_projects')->with('projects',$projects); $projectmachines = projectmachines::findOrFail($id); return view('dashboard.projects.view_projects', compact('projectmachines')); }

I need both project table and the projectmachines table view in the view_projects blade. I have already declared the relationships and access the model in controller. Once I give both as above then error comes like Undefined variable: projectmachines (View: C:\xampp\htdocs\MachineCenter\resources\views\dashboard\projects\view_projects.blade.php) and when commented the project table access it gives previous error and without projectmachines data this works properly

Could you please help me to solve this

Activity icon

Replied to Non-object Property

still it gives the same error

Activity icon

Started a new Conversation Non-object Property

public function show($id) { $arr['projectmachines'] = projectmachines::findOrFail($id); return view('dashboard.projects.view_projects')->with($arr); }

this is my controller and gives the error

Trying to get property of non-object (View: C:\xampp\htdocs\MachineCenter\resources\views\dashboard\projects\view_projects.blade.php)

for this for each loop

@foreach($projectmachines as $c) {{ $c->pm_mid }} {{ $c->pm_location }} {{ $c->pm_runit }} {{ $c->pm_mincharge }} {{ $c->pm_rental }} @endforeach

Jun
04
3 months ago
Activity icon

Replied to The Update Function Is Not Working

public function update(Request $request,Machines $machines) { $machines->m_gid = $request->m_gid; $machines->m_type = $request->m_type; $machines->m_enumber = $request->m_enumber; $machines->m_idate = $request->m_idate; $machines->m_seller = $request->m_seller; $machines->m_smobile = $request->m_smobile; $machines->m_saddress1 = $request->m_saddress1; $machines->m_saddress2 = $request->m_saddress2; $machines->m_saddress3 = $request->m_saddress3; $machines->m_notes = $request->m_notes; $machines->save(); return redirect()->route('dashboard.machines.index'); }

Activity icon

Replied to The Update Function Is Not Working

but again there is a problem. when I update it , it gives me new machine (row) with updated details. How can I solve it

Activity icon

Replied to The Update Function Is Not Working

Problem was solved and thank you very much for the help. is not there and I used @method ('PUT') instead. It is not working in my form

Activity icon

Replied to The Update Function Is Not Working

It is set but gives the error MethodNotAllowedHttpException still

Activity icon

Replied to The Update Function Is Not Working

Then it gives arr as undefined variable.

I couldn't get the second thing you mentioned since I new to laravel and this is my 1st project.Could you please explain it and give me a way to solve this.

Activity icon

Replied to The Update Function Is Not Working

@extends('layouts.dashboard') @section('content')

@method('PUT')
	<h1>Machine Center (Pvt.) Ltd.</h1>
	<h3>Update Machines</h3>

 <div class="form-group row">
 <label class="col-sm-3 col-form-label">1. Machine ID : </label>
<div class="col-sm-4">
 <input type="text" class="form-control" name="m_gid" value="{{($machines->m_gid)}}" >
</div>
<div class="form-group row">
 <label class="col-sm-3 col-form-label">2. Machine Type : </label>
 <div class="col-sm-4">
 <input type="text" class="form-control" name="m_type" value="{{($machines->m_type)}}"  >
</div>
3. Engine No./Serial No. : 4. Invoice Date: 5. Seller : 6. Contact number of Seller : 9. Address : 8. Special Notes : {{($machines->m_notes)}}                 Cancel

@endsection

Even after entering that it gives the same error

Jun
02
3 months ago
Activity icon

Replied to The Update Function Is Not Working

I used resource controller

Activity icon

Started a new Conversation The Update Function Is Not Working

This is my edit function and it takes data from the database and show.

public function edit($machines) { $arr['machines'] = Machines::find($machines); return view('dashboard.machines.edit_machines')->with($arr); }

But when I press update it gives the error (1/1) MethodNotAllowedHttpException and this does not send the data to the database.

public function update(Request $request,$machines) {

    $machines->m_gid = $request->m_gid;
    $machines->m_type = $request->m_type;
    $machines->m_enumber = $request->m_enumber;
    $machines->m_idate = $request->m_idate;
    $machines->m_seller = $request->m_seller;
    $machines->m_smobile = $request->m_smobile;
    $machines->m_saddress1 = $request->m_saddress1;
    $machines->m_saddress2 = $request->m_saddress2;
    $machines->m_saddress3 = $request->m_saddress3;
    $machines->m_notes = $request->m_notes;
    $machines->save();
    return redirect()->route('dashboard.machines.index');
}