<?phpnamespaceApp\Http\Controllers;useIlluminate\Http\Request;useIlluminate\Support\Facades\DB;classNewsControllerextendsController{/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/publicfunctionindex(){//$newsList=DB::table('news')->orderBy('id','desc')->get();returnview('index',compact('newsList'));}/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/publicfunctioncreate(){//returnview('addnews');}/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/publicfunctionstore(Request$request){//// dd($request->all());$data=$request->except('_token');$data['user_id']=1;// dd($data);$res=DB::table('news')->insert($data);if($res){returnredirect('/news');}}/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/publicfunctionshow($id){//$news=DB::table('news')->where('id',$id)->first();returnview('show',compact('news'));}/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/publicfunctionedit($id){//$news=DB::table('news')->find($id);returnview('edit',compact('news'));}/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/publicfunctionupdate(Request$request,$id){//// dd($request->all());$news=$request->except('_token','_method');$res=DB::table('news')->where('id',$id)->update($news);returnredirect('news');}/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/publicfunctiondestroy($id){//DB::table('news')->where('id',$id)->delete();returnredirect('news');}}