mercredi 13 février 2019

InvalidArgumentException on Laravel 5.7

i'm an absolute noob to Laravel this is my first day trying to use it, i'm doing an internship and the mentor over there recommended me the usage of Laravel 5.7 to create a CRUD as an example and to get me familiar with the framework so i can progress through my final year project, he also referred me to a tutorial to follow with, so i followed the tutorial step by step (was really troublesome at first as it turned out there was some error with migrations but managed to get it fixed after an hour or two of depression) later i progressed with the tutorial to the point where i'm supposed to test my create view as it turns it out everytime i try it returns an Invalid Argument Exception on produits.create, i checked comments from the tutorial and some people had my problem but no one suggested a working solution, i looked allover stackoverflow but it seems people had different problems to mine so it yielded no results

InvalidArgumentException
View [produits.create] not found.

This is the error i get

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ShareController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('produits.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

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

This is the Controller class

@extends('layout')

@section('content')
<style>
  .uper {
    margin-top: 40px;
  }
</style>
<div class="card uper">
  <div class="card-header">
    Ajouter Produit
  </div>
  <div class="card-body">
    @if ($errors->any())
      <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
              <li></li>
            @endforeach
        </ul>
      </div><br />
    @endif
      <form method="post" action="">
          <div class="form-group">
              @csrf
              <label for="nom">Nom Produit:</label>
              <input type="text" class="form-control" name="nom_produit"/>
          </div>
          <div class="form-group">
              <label for="prix">Prix Produit :</label>
              <input type="text" class="form-control" name="prix_produit"/>
          </div>
          <div class="form-group">
              <label for="quantite">Quantité Produit:</label>
              <input type="text" class="form-control" name="quantite_produit"/>
          </div>
          <button type="submit" class="btn btn-primary">Add</button>
      </form>
  </div>
</div>
@endsection

this is create.blade.php

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::resource('produits', 'ShareController');

This is web.php

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire