File tree 4 files changed +43
-3
lines changed
4 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,8 @@ public function show($id)
78
78
*/
79
79
public function edit ($ id )
80
80
{
81
- //
81
+ $ article =Article::where ('id ' ,$ id )->firstOrFail ();
82
+ return view ('admin.edit ' )->with ('article ' ,$ article );
82
83
}
83
84
84
85
/**
@@ -90,7 +91,13 @@ public function edit($id)
90
91
*/
91
92
public function update (Request $ request , $ id )
92
93
{
93
- //
94
+ $ article =Article::where ('id ' ,$ id )->firstOrFail ();
95
+ $ article ->update ([
96
+ 'body ' => $ request ->body ,
97
+ 'title ' => $ request ->title
98
+ ]);
99
+ $ request ->session ()->flash ('message ' ,'تم تعديل المقالة بنجاح ' );
100
+ return redirect ()->route ('admin_index ' );
94
101
}
95
102
96
103
/**
Original file line number Diff line number Diff line change
1
+ @extends (' layouts.app' )
2
+
3
+ @section (' admin_content' )
4
+ <script src =" https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy =" origin" ></script >
5
+ <script >
6
+ tinymce .init ({
7
+ selector: ' #mytextarea' ,
8
+ menubar: false ,
9
+ language: ' ar'
10
+ });
11
+ </script >
12
+
13
+ <div class =" card-header" >تعديل مقالة</div >
14
+
15
+ <div class =" card-body" >
16
+ <form class =" form-horizontal" action =" {{ url (' /admin/update/' . $article -> id )} }" method =" post" >
17
+ {{ csrf_field () } }
18
+ <input type =" hidden" name =" _method" value =" PUT" />
19
+ <div class =" form-group" >
20
+ <input class =" form-control" type =" text" name =" title" placeholder =" العنوان هنا" value =" {{ $article -> title } }" >
21
+ </div >
22
+ <div class =" form-group" >
23
+ <textarea name =" body" id =" mytextarea" >{{ $article -> body } } </textarea >
24
+ </div >
25
+ <div class =" form-group" >
26
+ <input class =" btn btn-success" type =" submit" value =" تعديل" />
27
+ </div >
28
+ </form >
29
+ </div >
30
+ @endsection
Original file line number Diff line number Diff line change 22
22
<th >ID</th >
23
23
<th >العنوان</th >
24
24
<th >تاريخ الإضافة</th >
25
+ <th >تعديل</th >
25
26
</tr >
26
27
<thead >
27
28
<tbody >
30
31
<td >{{ $article -> id } } </td >
31
32
<td >{{ $article -> title } } </td >
32
33
<td >{{ $article -> created_at } } </td >
34
+ <td ><a class =" btn btn-danger" href =" {{ url (' admin/edit/' . $article -> id )} }" >تعديل</a ></td >
33
35
</tr >
34
36
@endforeach
35
37
Original file line number Diff line number Diff line change 32
32
Route::get ('/ ' , 'HomeController@index ' )->name ('admin_index ' );
33
33
Route::get ('/create ' , 'ArticleController@create ' )->name ('article_create ' );
34
34
Route::post ('/store ' , 'ArticleController@store ' )->name ('article_create ' );
35
- Route::put ('/update ' , 'ArticleController@update ' )->name ('article_create ' );
35
+ Route::get ('/edit/{id} ' , 'ArticleController@edit ' )->name ('article_edit ' );
36
+ Route::put ('/update/{id} ' , 'ArticleController@update ' )->name ('article_create ' );
36
37
Route::put ('/delete ' , 'ArticleController@destroy ' )->name ('article_create ' );
37
38
});
You can’t perform that action at this time.
0 commit comments