Skip to content

Instantly share code, notes, and snippets.

@rawaludin
Created October 12, 2017 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rawaludin/5f19f046ba81fd2698d7d81e4abfc8ee to your computer and use it in GitHub Desktop.
Save rawaludin/5f19f046ba81fd2698d7d81e4abfc8ee to your computer and use it in GitHub Desktop.
@extends('layouts.app')
@section('content')
<div class="container">
<a href="{{ route('posts.create') }}" class="btn btn-default">Tulisan baru</a>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Judul</th>
</tr>
</thead>
<tbody>
@foreach ($posts as $post)
<tr>
<th scope="row">{{ $post->id }}</th>
<td>{{ $post->title }}</td>
<td>edit | hapus | lihat</td>
</tr>
@endforeach
</tbody>
</table>
<div class="row">
<div class="col-md-8 col-md-offset-2">
{{ $posts->links() }}
</div>
</div>
</div>
@endsection
@rawaludin
Copy link
Author

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        {!! Form::open(['route' => 'posts.store']) !!}
            <div class="form-group">
                {!! Form::label('Judul') !!}
                {!! Form::text('title', null, ['class' => 'form-control', 'placeholder' => 'Judul tulisan']) !!}
            </div>
            <div class="form-group">
                {!! Form::label('Konten') !!}
                {!! Form::textarea('content', null, ['class' => 'form-control', 'placeholder' => 'Isi artikel']) !!}
            </div>
            {!! Form::submit('Simpan', ['class' => 'btn btn-default']) !!}
		{!! Form::close() !!} 
    </div>
</div>
@endsection

@rawaludin
Copy link
Author

    public function store(Request $request)
    {
        $post = new Post();
        $post->title = $request->input('title');
        $post->content = $request->input('content');
        $post->save();
        return redirect()->route('posts.index');
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment