mercredi 6 juin 2018

Laravel 5.5, Default route for index not working for resource controller

I have a resource Controller named CmsPagesController,

class CmsPagesController extends Controller
{
/**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
    return 'something';
    // $pages=CmsPages::all();        
    // return view('backend.pages.cms.list')->with('pages',$pages);
}

public function list(){
    return '123';
}
/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
    return view('backend.pages.cms.add');
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
    $this->validate($request, [
        'name'      =>      'required',
        'slug'      =>  'required',
        'description'=> 'required'            
    ]);

    $Page=new CmsPages;
    $Page->name= $request->input('name');
    $Page->slug= $request->input('slug');
    $Page->description= $request->input('description');
    $Page->copyright= $request->input('copyright');
    $Page->keywords= $request->input('keywords');


    $Page->save();

    return redirect('/admin/pages')->with('success','Page Added Successfully');
}

/**
 * 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)
{
    //
}
}

My Add function and store function is working perfect, I can render add page and can store data to database but my index function is not working, I have placed a sample return statement but that is not executed as well. what am I missing



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire