Today I started to use Laravel-nestable for creating a selection box, I followed all the steps, and I receive thiserror: Class 'App\Http\Controllers\Category' not found.
I tried looking for a answer but couldnt find it. What am I doing wrong?
I'm using Laravel 5.4.
Here is my code:
`<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator, DB;
use Nestable\NestableTrait;
class FinanceController extends Controller {
use NestableTrait;
protected $parent = 'parent_id';
private $resultsPerPage = 10;
public function index() {
$results = DB::table('finance')->simplePaginate($this->resultsPerPage);
$categories = Category::nested()->get();
return view('finance.index', ['results' => $results]);
}
public function create() {
return view('finance.create');
}
// Function: store
// Description: Check if all the required values are filled in.
// Returned view: finance.index
public function store(Request $request) {
// First validate if all the required fields are filled in
$validater = Validator::make($request->all(), [
'transactionDate' => 'required',
'transactionDescription' => 'required|max:255',
'transactionCategorie' => 'required',
'transactionPaymentMethod' => 'required',
'transactionType' => 'required',
'transactionAmount' => 'required'
]);
if ($validater->passes()) {
//Insert the data in the database
$validateInsert = DB::table('finance')->insert([
'date' => $request->transactionDate,
'description' => $request->transactionDescription,
'categorie' => $request->transactionCategorie,
'paymentMethod' => $request->transactionPaymentMethod,
'type' => $request->transactionType,
'amount' => $request->transactionAmount
]);
//Return to the index view
return view('finance.index');
} else {
// If validation failed, return to the previous file, with the errors and inputs
return redirect('finance.create')->withErrors($validater)->withInput();
}
}
public function show($id) {
//
}
public function edit($id) {
//
}
public function update(Request $request, $id) {
//
}
public function destroy($id) {
//
}
// Custom functions
public function overview() {
$results = DB::table('finance')->simplePaginate($this->resultsPerPage);
return view('finance.overview', ['results' => $results]);
}
public function print() {
return view('finance.print');
}
Hi all,
Today I started to use Laravel-nestable for creating a selection box, I followed all the steps, and I receive thiserror: Class 'App\Http\Controllers\Category' not found.
I tried looking for a answer but couldnt find it. What am I doing wrong?
I'm using Laravel 5.4.
Here is my code: `<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request; use Validator, DB; use Nestable\NestableTrait;
class FinanceController extends Controller { use NestableTrait;
} `