waktu tersisa untuk klaim DISKON 40% dalam program Full Stack Membership. Klaim Promo!

Gagal pada saat membuat breadcrumbs

Ditanyakan pada tanggal 27 June 2020 oleh Wan M Johan Ramadhan Edit  Hapus  Tandai Selesai  Tandai 
Facade\Ignition\Exceptions\ViewException

Trying to get property 'title' of non-object (View: C:\xampp\htdocs\codepolitan\perpus\resources\views\admin\templates\default.blade.php)

http://127.0.0.1:8000/admin/author

ini pesan eror yang muncul. Tolong solusinya pak
Comment ..

apakah sudah solved? saya gagal juga ternyata

Dikomentari 4 hari yang lalu oleh ilham fadhilah Edit  Remove 
BUAT KOMENTAR

1 JAWABAN / 2 KOMENTAR

User avatar
Ahmad Oriza menjawab pada tanggal 1 July 2020 Jadikan Jawaban Terbaik  Edit  Hapus  Ubah ke Komentar 

Pertama tama pastikan database structure sudah sama, coba cek lagi tabel author dan book apakah ada data yang ketinggalan? pastikan juga sudah ada isinya.

Coba cek lagi controllernya

<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Author;

class AuthorController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('admin.author.index', [
            'title' => 'Data Penulis',
        ]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.author.create', [
            'title' => 'Tambah Penulis',
        ]);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required|min:3'
        ]);

        Author::create($request->only('name'));

        return redirect()->route('admin.author.index')
                    ->with('success', 'Data penulis berhasil ditambahkan');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit(Author $author)
    {
        return view('admin.author.edit', [
            'title' => 'Edit Penulis',
            'author' => $author,
        ]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Author $author)
    {
        $this->validate($request, [
            'name' => 'required|min:3'
        ]);

        $author->update($request->only('name'));

        return redirect()->route('admin.author.index')
                    ->with('info', 'Data penulis berhasil diupdate');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy(Author $author)
    {
        $author->delete();

        return redirect()->route('admin.author.index')
                    ->with('danger', 'Data penulis berhasil dihapus');
    }
}

Model author

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Author extends Model
{
    protected $guarded = [];

    public $timestamps = false;

    public function books()
    {
        return $this->hasMany(Book::class);
    }
}

View author

@extends('admin.templates.default')

@section('content')
<div class="box">
    <div class="box-header">
        <h3 class="box-title">Data Penulis</h3>
        <a href="{{ route('admin.author.create') }}" class="btn btn-primary">Tambah Penulis</a>
    </div>

    <div class="box-body">

        <table id="dataTable" class="table table-bordered table-hover">
            <thead>
                <tr>
                    <th>Id</th>
                    <th>Nama</th>
                    <th>Aksi</th>
                </tr>
            </thead>
        </table>
    </div>
</div>

<form action="" method="post" id="deleteForm">
    @csrf
    @method("DELETE")
    <input type="submit" value="Hapus" style="display: none">
</form>
@endsection

@push('styles')
<link rel="stylesheet" href="{{ asset('assets/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') }}">
@endpush

@push('scripts')
    <script src="{{ asset('assets/bower_components/datatables.net/js/jquery.dataTables.min.js') }}"></script>
    <script src="{{ asset('assets/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') }}"></script>
    <script src="{{ asset('assets/plugins/bs-notify.min.js') }}"></script>
    @include('admin.templates.partials.alerts')
    <script>
        $(function () {
            $('#dataTable').DataTable({
                processing: true,
                serverSide: true,
                ajax: '{{ route('admin.author.data') }}',
                columns: [
                    { data: 'DT_RowIndex', orderable: false, searchable : false},
                    { data: 'name'},
                    { data: 'action'}
                ]
            });
        });
    </script>
@endpush

Template dafault

<!DOCTYPE html>
<html>

@include('admin.templates.partials.head')

<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    @include('admin.templates.partials.header')
  <!-- Left side column. contains the logo and sidebar -->
    @include('admin.templates.partials.sidebar')

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">

    <section class="content-header">
      <h1>
        {{ Breadcrumbs::current()->title }}
      </h1>
      {{ Breadcrumbs::render() }}
      {{-- <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Dashboard</li>
      </ol> --}}
    </section>
    <!-- Main content -->
    <section class="content">
      @yield('content')
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
    @include('admin.templates.partials.footer')

  <!-- Control Sidebar -->
    @include('admin.templates.partials.control')
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->
    @include('admin.templates.partials.scripts')
</body>
</html>
Comment ..

sudah sama mas, tetap tidak mau juga, mungkin harus ngikutin step yg ke 3 sperti yang ada di dokumentasi github nya

Dikomentari pada tanggal 6 July 2020 oleh Wan M Johan Ramadhan Edit  Remove 
BUAT KOMENTAR