Error css dan js notfound pada laravel

Kira kira error nya kenapa ya padahal extends dan semuanya udh bener , form lain juga normal normal aja, hanya saja form edit error kira kira kenapa ya pas saya inspect css dan js nya notfound, dan juga tidak bisa melakukan perulangan atau menggunakan php di form ini errornya Trying to get property of non-object, dan pas perulangan saya hapus css dan js nya tidak jalan ini sc nya :

edit.blade.php :

@extends('main.layout')
@section('title','Selamat Datang Partner')
@section('container')
<div class="wrapper ">
    <div class="main-panel" id="main-panel">
      <!-- Navbar -->
      <nav class="navbar navbar-expand-lg navbar-transparent  bg-primary  navbar-absolute">
        <div class="container-fluid">
          <div class="navbar-wrapper">
            <div class="navbar-toggle">
              <button type="button" class="navbar-toggler">
                <span class="navbar-toggler-bar bar1"></span>
                <span class="navbar-toggler-bar bar2"></span>
                <span class="navbar-toggler-bar bar3"></span>
              </button>
            </div>
            <a class="navbar-brand" href="#pablo">Tambah Data Barang</a>
          </div>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-bar navbar-kebab"></span>
            <span class="navbar-toggler-bar navbar-kebab"></span>
            <span class="navbar-toggler-bar navbar-kebab"></span>
          </button>
          <div class="collapse navbar-collapse justify-content-end" id="navigation">
            <form>
              <div class="input-group no-border">
                <input type="text" value="" class="form-control" placeholder="Search...">
                <div class="input-group-append">
                  <div class="input-group-text">
                    <i class="now-ui-icons ui-1_zoom-bold"></i>
                  </div>
                </div>
              </div>
            </form>
            <ul class="navbar-nav">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                      <i class="now-ui-icons location_world"></i>
                      <p>
                        <span class="d-lg-none d-md-block">Some Actions</span>
                      </p>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
                      <a class="dropdown-item" href="#">Settings</a>
                      <a class="dropdown-item" href="#">Partners</a>
                      <a class="dropdown-item text-danger" href="#">Logout</a>
                    </div>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" href="#pablo">
                      <i class="now-ui-icons users_single-02"></i>
                      <p>
                        <span class="d-lg-none d-md-block">Account</span>
                      </p>
                    </a>
                  </li>
                </ul>
          </div>
        </div>
      </nav>
      <!-- End Navbar -->
      <div class="panel-header panel-header-sm">
      </div>
      <div class="content">
        <div class="row">
          <div class="col-md-8">
            <div class="card">
              <div class="card-header">
                <h5 class="title">Tambah Data Barang</h5>
              </div>
              <div class="card-body">
                <form action="/goods/create" method="post">
                  @csrf
                    <div class="form-group">
                        <label for="kd_barang">Kode Barang</label>
                        <input type="text" class="form-control" name="kd_barang" id="kd_barang">
                      </div>
                    <div class="form-group">
                        <label for="nama_barang">Nama Barang</label>
                        <input type="text" class="form-control" name="nama_barang" id="nama_barang">
                      </div>
                    <div class="form-group">
                        <label for="kategori">Kategori</label>
                        <input type="text" class="form-control" name="kategori" id="kategori">
                      </div>
                    <div class="form-group">
                        <label for="stok_barang">Stok Barang</label>
                        <input type="number" class="form-control" name="stok_barang" id="stok_barang">
                      </div>
                      <button type="submit" class="btn btn-primary">Tambah</button>
                      <a href="/" class="btn btn-info">Kembali</a>
                    </form>
              </div>
            </div>
          </div>
          <div class="col-md-4">
            <div class="card card-user">
              <div class="image">
                <img src="../assets/img/bg5.jpg" alt="...">
              </div>
              <div class="card-body">
                  <ul class="list-group">
                      @foreach ($goods as $g)
                    <li class="list-group-item d-flex justify-content-between align-items-center">
                     {{$g->nama_barang}} :
                     {{$g->stok_barang}}

                      @endforeach
                    </li>
                  </ul>
                </div>
               <?php
                $total = 0;
                foreach ($goods as $g)
                {
                  $total +=$g['stok_barang'];
                }

                ?>
                <ul>
                <li>
                <?php
                echo "Total Keseluruhan Stok Barang = " . $total
                ?>
                </li>
                </ul>

                  @if (session('status'))
                  <div class="alert alert-success mb-4">
                      {{ session('status') }}
                  </div>
              @endif
              </div>
          </footer>
    </div>
  </div>
@endsection

Ini Controller nya : goodsController.php :

<?php

namespace App\Http\Controllers;

use App\Good;
use Illuminate\Http\Request;

class goodsController extends Controller
{
    /**
     * Display a listing of the resource.
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $goods = Good::all();
        return view('home.index',compact('goods'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $goods = Good::all();
        return view('home.create',compact('goods'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        Good::create($request->all());
        return redirect('/goods/create')->with('status','Data Barang Berhasil Di tambahkan');
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Good  $goods
     * @return \Illuminate\Http\Response
     */
    public function show(Good $goods)
    {
        return view('home.show',compact('goods'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Good  $goods
     * @return \Illuminate\Http\Response
     */
    public function edit(Good $goods)
    {
        return view('home.edit',compact('goods'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Good  $goods
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, good $good)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Good  $goods
     * @return \Illuminate\Http\Response
     */
    public function destroy(Good $goods)
    {
        Good::destroy($goods->id);
        return redirect('/')->with('status','Data Barang Berhasil Di Hapus');
    }
}

Ini Web.php nya :

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'goodsController@index');
Route::get('/goods/create','goodsController@create');
Route::get('/goods/{goods}','goodsController@show');
Route::post('/goods/create','goodsController@store');
Route::delete('/goods/{goods}','goodsController@destroy');
Route::get('/goods/{goods}/edit','goodsController@edit');

// Route::resource('goods','goodsController');
// Route::get('/',function(){
//     return view('home.index');
// });

Ini Show.blade.php Tempat Dimana Tombol Edit :

@extends('main.layout')
@section('title','Selamat Datang Partner')
@section('container')
<div class="main-panel" id="main-panel">
  <!-- Navbar -->
  <nav class="navbar navbar-expand-lg navbar-transparent  bg-primary  navbar-absolute">
      <div class="container-fluid">
        <div class="navbar-wrapper">
          <div class="navbar-toggle">
            <button type="button" class="navbar-toggler">
              <span class="navbar-toggler-bar bar1"></span>
              <span class="navbar-toggler-bar bar2"></span>
              <span class="navbar-toggler-bar bar3"></span>
            </button>
          </div>
        <a class="navbar-brand" href="#pablo">Details : {{$goods->kd_barang}}</a>
        </div>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-bar navbar-kebab"></span>
          <span class="navbar-toggler-bar navbar-kebab"></span>
          <span class="navbar-toggler-bar navbar-kebab"></span>
        </button>
        <div class="collapse navbar-collapse justify-content-end" id="navigation">
          <form>
            <div class="input-group no-border">
              <input type="text" value="" class="form-control" placeholder="Search...">
              <div class="input-group-append">
                <div class="input-group-text">
                  <i class="now-ui-icons ui-1_zoom-bold"></i>
                </div>
              </div>
            </div>
          </form>
          <ul class="navbar-nav">
            {{-- <li class="nav-item">
              <a class="nav-link" href="#pablo">
                <i class="now-ui-icons media-2_sound-wave"></i>
                <p>
                  <span class="d-lg-none d-md-block">Stats</span>
                </p>
              </a>
            </li> --}}
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  <i class="now-ui-icons location_world"></i>
                  <p>
                    <span class="d-lg-none d-md-block">Some Actions</span>
                  </p>
                </a>
                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
                  <a class="dropdown-item" href="#">Settings</a>
                  <a class="dropdown-item" href="#">Partners</a>
                  <a class="dropdown-item text-danger" href="#">Logout</a>
                </div>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#pablo">
                  <i class="now-ui-icons users_single-02"></i>
                  <p>
                    <span class="d-lg-none d-md-block">Account</span>
                  </p>
                </a>
              </li>
            </ul>
          </div>
        </div>
      </nav>
    <!-- End Navbar -->
    <div class="panel-header panel-header-sm">
    </div>
    <div class="content">
      <div class="row">
        <div class="col-md-8 ml-auto mr-auto">
          <div class="card card-upgrade">
            <div class="card-header text-center">
              <h4 class="card-title">{{$goods->nama_barang}}</h3>
                <p class="card-category">{{$goods->kd_barang}}</p>
            </div>
            <div class="card-body">
              <div class="table-responsive table-upgrade">
                <table class="table">
                  <thead>
                    <th class="text-center">Kategori</th>
                    <th class="text-center">Stok Barang</th>
                    <th class="text-center">Aksi</th>
                  </thead>
                  <tbody>
                    <tr>
                    <td>{{$goods->kategori}}</td>
                      <td class="text-center">{{$goods->stok_barang}}</td>
                      <td class="text-center">
                        <a href="{{$goods->id}}/edit" class="btn btn-info">Edit</a>
                      <form action="{{$goods->id}}" method="post" class="d-inline">
                        @method('delete')
                        @csrf
                        <button type="submit" class="btn btn-danger">Hapus</button>
                        </form>
                          {{-- <a href="" class="btn btn-primary ">Print</a>   --}}
                        </td>
                      </tr>
                    </tr>
                  </tbody>
                </table>
                <a href="/" class="btn btn-info ">kembali</a>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <footer class="footer">
      <div class="container-fluid">
        <nav>
          <ul>
            <li>
              <a href="https://www.creative-tim.com">
                Creative Tim
              </a>
            </li>
            <li>
              <a href="http://presentation.creative-tim.com">
                About Us
              </a>
            </li>
            <li>
              <a href="http://blog.creative-tim.com">
                Blog
              </a>
            </li>
          </ul>
        </nav>
        <div class="copyright" id="copyright">
          ©
          <script>
            document.getElementById('copyright').appendChild(document.createTextNode(new Date().getFullYear()))
          </script>, Designed by
          <a href="https://www.invisionapp.com" target="_blank">Invision</a>. Coded by
          <a href="https://www.creative-tim.com" target="_blank">Creative Tim</a>.
        </div>
      </div>
    </footer>
  </div>
</div>
@endsection

Mohon Bantuannya Trimakasih :)

avatar jiasfjabfie1212
@jiasfjabfie1212

38 Kontribusi 0 Poin

Diperbarui 5 tahun yang lalu

2 Jawaban:

Jawaban Terpilih

Error : <pre> Trying to get property of non-object </pre> karena object $goods tidak ada isinya. Coba aja di dd <pre> public function edit(Good $goods) { dd($goods) return view('home.edit',compact('goods')); } </pre> outputnya, InsyaAllah pastinya NULL

avatar mrizkiromdoni
@mrizkiromdoni

78 Kontribusi 26 Poin

Dipost 5 tahun yang lalu

Tanggapan

trus solusinya Gimana?

coba seperti ini <pre>

public function edit(Request $id) { $goods = Goods::find($id);

    return view(&#039;home.edit&#039;)-&amp;gt;with([&#039;goods&#039;=&amp;gt;$goods]);
}

</pre>

avatar mrizkiromdoni
@mrizkiromdoni

78 Kontribusi 26 Poin

Dipost 5 tahun yang lalu

Login untuk ikut Jawaban