I am trying to insert data into my database but this error shows up:
Illuminate\Contracts\Container\BindingResolutionException
Target class [App\Http\Controllers\Master\Request] does not exist.
Though my Vendor Model and VendorController is in right directory.
Here's my Vendor Model source code (\app\Model\Master):
<?php
namespace App\Model\Master;
use Illuminate\Database\Eloquent\Model;
class Vendor extends Model
{
protected $table = 'vendors';
public function user_modify()
{
return $this->belongsTo('\App\User', 'user_modified');
}
}
Here's my VendorController source code (\app\Http\Controllers\Master):
<?php
namespace App\Http\Controllers\Master;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
class VendorController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view("vendor.index");
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view("vendor.create");
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$data = new Vendor();
$data->vendor_firstname = $request->first_name;
$data->vendor_lastname = $request->last_name;
$data->vendor_address = $request->address;
$data->vendor_phone = $request->contact;
$data->vendor_firstname = $request->first_name;
$data->active = $request->vendor_status;
$data->vendor_modified = Auth::user()->id;
if($data->save()){
return redirect()->route('vendor.index');
}else{
return redirect()->back();
}
}
/**
* 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)
{
//
}
}
And here's my route list:
What causes this error? And how do I fix it? tried running php artisan config:cache and composer dump-autoload but still no luck..
use Illuminate\Http\Request;
place this in your controller, and i would recommend to make controllers and other stuff through cmd, do not copy and paste. – Akhtar Munir