@@ -46,7 +46,7 @@ public function __construct(
4646 $ this ->nbrPages = 2 ;
4747
4848 $ this ->middleware ('redac ' , ['except ' => ['indexFront ' , 'show ' , 'tag ' , 'search ' ]]);
49- $ this ->middleware ('ajax ' , ['only ' => ['indexOrder ' , ' updateSeen ' , 'updateActive ' ]]);
49+ $ this ->middleware ('ajax ' , ['only ' => ['updateSeen ' , 'updateActive ' ]]);
5050 }
5151
5252 /**
@@ -57,25 +57,22 @@ public function __construct(
5757 public function indexFront ()
5858 {
5959 $ posts = $ this ->blog_gestion ->indexFront ($ this ->nbrPages );
60- $ links = str_replace ( ' /? ' , ' ? ' , $ posts ->render () );
60+ $ links = $ posts -> setPath ( '' ) ->render ();
6161
6262 return view ('front.blog.index ' , compact ('posts ' , 'links ' ));
6363 }
6464
6565 /**
6666 * Display a listing of the resource.
6767 *
68- * @param Illuminate\Contracts\Auth\Guard $auth
69- * @return Response
68+ * @return Redirection
7069 */
71- public function index (Guard $ auth )
70+ public function index ()
7271 {
73- $ statut = $ this ->user_gestion ->getStatut ();
74- $ posts = $ this ->blog_gestion ->index (10 , $ statut == 'admin ' ? null : $ auth ->user ()->id );
75-
76- $ links = str_replace ('/? ' , '? ' , $ posts ->render ());
77-
78- return view ('back.blog.index ' , compact ('posts ' , 'links ' ));
72+ return redirect (route ('blog.order ' , [
73+ 'name ' => 'created_at ' ,
74+ 'sens ' => 'asc '
75+ ]));
7976 }
8077
8178 /**
@@ -87,14 +84,28 @@ public function index(Guard $auth)
8784 public function indexOrder (Request $ request )
8885 {
8986 $ statut = $ this ->user_gestion ->getStatut ();
90- $ posts = $ this ->blog_gestion ->index (10 , $ statut == 'admin ' ? null : $ request ->user ()->id , $ request ->input ('name ' ), $ request ->input ('sens ' ));
87+ $ posts = $ this ->blog_gestion ->index (
88+ 10 ,
89+ $ statut == 'admin ' ? null : $ request ->user ()->id ,
90+ $ request ->name ,
91+ $ request ->sens
92+ );
9193
92- $ links = str_replace ('/? ' , '? ' , $ posts ->render ());
94+ $ links = $ posts ->appends ([
95+ 'name ' => $ request ->name ,
96+ 'sens ' => $ request ->sens
97+ ]);
98+
99+ if ($ request ->ajax ()) {
100+ return response ()->json ([
101+ 'view ' => view ('back.blog.table ' , compact ('statut ' , 'posts ' ))->render (),
102+ 'links ' => $ links ->setPath ('order ' )->render ()
103+ ]);
104+ }
93105
94- return response ()->json ([
95- 'view ' => view ('back.blog.table ' , compact ('statut ' , 'posts ' ))->render (),
96- 'links ' => $ links
97- ]);
106+ $ links ->setPath ('' )->render ();
107+
108+ return view ('back.blog.index ' , compact ('posts ' , 'links ' ));
98109 }
99110
100111 /**
@@ -225,7 +236,7 @@ public function tag(Request $request)
225236 {
226237 $ tag = $ request ->input ('tag ' );
227238 $ posts = $ this ->blog_gestion ->indexTag ($ this ->nbrPages , $ tag );
228- $ links = str_replace ( ' /? ' , ' ? ' , $ posts ->appends (compact ('tag ' ))->render () );
239+ $ links = $ posts -> setPath ( '' ) ->appends (compact ('tag ' ))->render ();
229240 $ info = trans ('front/blog.info-tag ' ) . '<strong> ' . $ this ->blog_gestion ->getTagById ($ tag ) . '</strong> ' ;
230241
231242 return view ('front.blog.index ' , compact ('posts ' , 'links ' , 'info ' ));
@@ -241,7 +252,7 @@ public function search(SearchRequest $request)
241252 {
242253 $ search = $ request ->input ('search ' );
243254 $ posts = $ this ->blog_gestion ->search ($ this ->nbrPages , $ search );
244- $ links = str_replace ( ' /? ' , ' ? ' , $ posts ->appends (compact ('search ' ))->render () );
255+ $ links = $ posts -> setPath ( '' ) ->appends (compact ('search ' ))->render ();
245256 $ info = trans ('front/blog.info-search ' ) . '<strong> ' . $ search . '</strong> ' ;
246257
247258 return view ('front.blog.index ' , compact ('posts ' , 'links ' , 'info ' ));
0 commit comments