# data[].attributes.body
Sek kito jange pecoh
Sek kito jange pecoh
Sek kito jange pecoh
Sek kito jange pecoh
Sek kito jange pecoh
Sek kito jange pecoh
Sek kito jange pecoh
Sek kito jange pecohSek kito jange pecoh
Sek kito jange pecoh
Pochinki for life

# data[].attributes.body
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/......./.......git
git push -u origin master

# data[].attributes.body
Route [posts.update] not defined. (View: C:\xampp\htdocs\blog\resources\views\post\edit.blade.php)

# data[].attributes.body
Creating default object from empty value

# data[].attributes.body
tgk ada s ke tak kat $post

# data[].attributes.body
Undefined variable: post (View: C:\xampp\htdocs\blog\resources\views\post\edit.blade.php)

# data[].attributes.body
syntax error, unexpected 'post' (T_STRING), expecting variable (T_VARIABLE) or '{' or '$' (View: C:\xampp\htdocs\blog\resources\views\post\index.blade.php)

# data[].attributes.body
<form action="{{ route('posts.update', $post) }}" method="post" enctype="multipart/form-data">

{{ csrf_field() }}

Title:

<input type="text" name="title" value="{{ $post->title }}">

<br>

Content:

<textarea name="content" id="" cols="30" rows="10">{{ $post->content }}</textarea>

<br>

Image:

<img width="60" src="{{ asset('storage/'.$post->image) }}" alt="">

<input type="file" name="image">

<button type="submit">Save</button>

<button type="submit" formaction="{{ route('posts.delete', $post) }}">Delete</button>

</form>

# data[].attributes.body
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Post;

class PostController extends Controller

{

public function index()

{

$post = new Post;

$posts = $post->all();

return view('post.index', [

'posts' => $posts

]);

}

public function create()

{

return view('post.create');

}

public function store(Request $request)

{

$post = new Post;

$post->title = $request->title;

$post->content = $request->content;

if ($request->hasFile('image')) {

$post->image = $request->image->store('images', 'public');

} else {

$post->image = '';

}

$post->save();

return redirect()->route('posts.index');

}

public function edit(Post $post)

{

return view('post.edit', [

'post' => $post

]);

}

public function update(Request $request, Post $post)

{

$post->title = $request->title;

$post->content = $request->content;

if ($request->hasFile('image')) {

$post->image = $request->image->store('images', 'public');

}

$post->save();

return redirect()->route('posts.index');

}

public function delete(Post $post)

{

$post->delete();

return redirect()->route('posts.index');

}

}

# data[].attributes.body
<ul>

@foreach ($posts as $post)

<li>

<a href="{{ route('posts.edit', $post) }}">

{{ $post->title }}

</a>

<img width="60" src="{{ asset('storage/'.$post->image) }}" alt="">

</li>

@endforeach

</ul>

<a href="{{ route('posts.create') }}">Add post</a>