Skip to content

Instantly share code, notes, and snippets.

@kartagis
Last active April 5, 2019 17:28
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 kartagis/e2c6d9ef8fb04362d5e9354b37630e97 to your computer and use it in GitHub Desktop.
Save kartagis/e2c6d9ef8fb04362d5e9354b37630e97 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class BlogController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$posts = DB::table('blog')->get();
return view('blog.index')->with(compact('posts'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* 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($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
@extends('main')
@section('content')
@if (!$posts->isEmpty())
@foreach($posts as $post)
<a href="posts/{id}">{{ $post->body }}</a>
@endforeach
@else
{{ No posts found. }}
@endif
@endsection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment