mirror of
https://github.com/Aviortheking/CA_LARAVEL.git
synced 2025-04-22 10:52:14 +00:00
add blog detail
This commit is contained in:
parent
092e42e197
commit
a09f9b317b
@ -3,7 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Post;
|
||||||
use DB;
|
use DB;
|
||||||
|
|
||||||
class HomeController extends Controller
|
class HomeController extends Controller
|
||||||
@ -41,4 +41,7 @@ class HomeController extends Controller
|
|||||||
|
|
||||||
return view('blog', ['posts' => $posts]);
|
return view('blog', ['posts' => $posts]);
|
||||||
}
|
}
|
||||||
|
public function detail($id) {
|
||||||
|
return view('detail',['post' => Post::findOrFail($id)]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
|
|
||||||
<h1 style="color:black"> Nos articles : </h1>
|
<h1 style="color:black"> Nos articles : </h1>
|
||||||
@foreach ($posts as $post)
|
@foreach ($posts as $post)
|
||||||
|
<a href="{{ url('/blog/detail',$post->id) }}">
|
||||||
<div style="color:black; background-color: white; width:300px; height:40px;margin:auto">
|
<div style="color:black; background-color: white; width:300px; height:40px;margin:auto">
|
||||||
<h2>{{ $post->title }}</h2>
|
<h2>{{ $post->title }}</h2>
|
||||||
<!-- <p>sdq</p> -->
|
<!-- <p>sdq</p> -->
|
||||||
</div>
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
9
resources/views/detail.blade.php
Normal file
9
resources/views/detail.blade.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
@extends('layout')
|
||||||
|
@section('title')
|
||||||
|
<title>{{$post->title}}</title>
|
||||||
|
@endsection
|
||||||
|
@section('content')
|
||||||
|
<h2 style="color:black; margin-top:100px">{{$post->title}}</h2>
|
||||||
|
<p style="color:black; width:80%; margin:auto; font-size:20px;">{{$post->content}} </p>
|
||||||
|
<a href="{{ url('/blog') }}">Liste des articles</a>
|
||||||
|
@endsection
|
@ -23,3 +23,5 @@ Auth::routes();
|
|||||||
Route::get('/home', 'HomeController@index')->name('home');
|
Route::get('/home', 'HomeController@index')->name('home');
|
||||||
Route::get('admin/home', 'HomeController@adminHome')->name('admin.home')->middleware('is_admin');
|
Route::get('admin/home', 'HomeController@adminHome')->name('admin.home')->middleware('is_admin');
|
||||||
Route::get('/blog', 'HomeController@blog')->name('blog');
|
Route::get('/blog', 'HomeController@blog')->name('blog');
|
||||||
|
Route::get('/blog/detail/{id}', 'HomeController@detail')->name('detail');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user