+--------+----------+-------------------------+-------+--------------------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-------------------------+-------+--------------------------------------------------------+--------------+
| | GET|HEAD | / | | App\Http\Controllers\HomeController@index | web,auth |
| | POST | / | | App\Http\Controllers\HomeController@newsSubmit | web |
| | POST | announcement/get/fields | | App\Http\Controllers\HomeController@newsGetFields | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | GET|HEAD | login | login | App\Http\Controllers\UserController@login | web |
| | POST | login/user | | App\Http\Controllers\UserController@loginUser | web |
| | POST | notifications/get | | App\Http\Controllers
otificationsController@getNotif | web |
| | POST | notifications/read | | App\Http\Controllers
otificationsController@readNotif | web |
| | GET|HEAD | notifications/view | | App\Http\Controllers
otificationsController@index | web |
| | GET|HEAD | register | | App\Http\Controllers\UserController@register | web |
| | POST | register/user | | App\Http\Controllers\UserController@registerUser | web |
+--------+----------+-------------------------+-------+--------------------------------------------------------+--------------+
Those are all my routes:
//notifications
Route::post('/notifications/get', 'notificationsController@getNotif');
Route::post('/notifications/read', 'notificationsController@readNotif');
Route::get('/notifications/view', 'notificationsController@index');
And this is my controller:
<?php
namespace App\Http\Controllers;
use App
otifications;
use Illuminate\Http\Request;
class notificationsController extends Controller
{
public function getNotif(Request $request)
{
$id = $request->input('id');
$notifResult = notifications::orderBy('id', 'desc')->where('userID', '=', $id)->where('readed', '=', 0)->get();
$data = array(
'notifResult' => $notifResult,
'notifNumber' => count($notifResult)
);
return $data;
}
public function readNotif(Request $request)
{
$notifid = $request->input('id');
$findNotif = notifications::findOrFail($notifid);
$findNotif->readed = 1;
$findNotif->save();
}
public function index()
{
return view('notifications');
}
}
Only the index one is not working.
I am trying to display all the notifications when clicking on "View all", View all would take the user to /notifications/view which works but when I get there, I get the "Method [index] does not exist."
error, and that is, I assume public function index()
.
I forgot to save the file....
Tried to clear your view and simple cache. It could be due to cache.