"404 Not Found" for newly created Resources using Laravel - mysql

I am trying to create a webpage with Laravel (5.8.35) / MySQL using XAMPP.
After setting up the DB and initializing it with some test data I wanted to create some resources to retreive the data (of students in my case).
The standard Laravel landing page in my case is located at localhost/testlaravel/public. I am trying to access the resource on localhost/testlaravel/public/api/students which results in a 404 | Not Found.
What could the problem be? Thank you in advance
Here are a few code snippets of hopefully all relevant files.
routes\api.php
// List students
Route::get('/students','StudentController#index');
// List single student
Route::get('/student/{id}', 'StudentController#show');
App\Http\Controllers\StudentController
public function index() {
$students = Student::paginate(20);
return StudentResource::collection($students);
}
App\Http\Resources\StudentResource
public function toArray($request) {
return parent::toArray($request);
}
Edit1:
The console output for php artisan route:list is:
+--------+----------+------------------+------+------------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+------------------+------+------------------------------------------------+--------------+
| | GET|HEAD | / | | Closure | web |
| | POST | api/student | | App\Http\Controllers\StudentController#store | api |
| | GET|HEAD | api/student/{id} | | App\Http\Controllers\StudentController#show | api |
| | PUT | api/student/{id} | | App\Http\Controllers\StudentController#update | api |
| | DELETE | api/student/{id} | | App\Http\Controllers\StudentController#destroy | api |
| | GET|HEAD | api/students | | App\Http\Controllers\StudentController#index | api |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | POST | student | | App\Http\Controllers\StudentController#store | web |
| | GET|HEAD | student/{id} | | App\Http\Controllers\StudentController#show | web |
| | PUT | student/{id} | | App\Http\Controllers\StudentController#update | web |
| | DELETE | student/{id} | | App\Http\Controllers\StudentController#destroy | web |
| | GET|HEAD | students | | App\Http\Controllers\StudentController#index | web |
+--------+----------+------------------+------+------------------------------------------------+--------------+```

You are saying, you want to create a webPage so i think you have to add the Route to routes/web.php file for web pages routes/api.php is for api's
if you are creating api, check if XAMPP is functioning also may be some connection issues
like your ip address

Related

How to make galera node run independently

I have 2 nodes of MySQL Galera cluster. I want to make it run independently when it's disconnected from each other. But it seems that it's becoming an initialized state even after I enabled below option:
SET GLOBAL wsrep_provider_options='pc.ignore_sb=TRUE';
It's showing below when the node is disconnected from the network:
| wsrep_local_state_comment | Initialized |
| wsrep_cert_index_size | 14 |
| wsrep_causal_reads | 0 |
| wsrep_cert_interval | 0.086022 |
| wsrep_open_transactions | 0 |
| wsrep_open_connections | 0 |
| wsrep_incoming_addresses | 10.201.127.76:3306 |
| wsrep_cluster_weight | 0 |
| wsrep_desync_count | 0 |
| wsrep_evs_delayed | |
| wsrep_evs_evict_list |
Any idea how to make it run independently even if the network is down?
Thanks!

How to select query for certain value in MySQL query?

I have problem with my SQL query. I wanted to display data that their file condition = no and status condition not equal to pending-update.
This is my current table
| name | file | status |
----------------------------------
| willy | no | pending |
| ash | no | |
| wiki | no | pending |
| Windy | no | pending-update|
| wilma | no | |
-----------------------------
I would like to create a query that will display only this output
| name | file | status |
-----------------------------
| willy | no | pending |
| ash | no | |
| wiki | no | pending |
| wilma | no | |
-----------------------------
As the output data for ash and wilma the value of the column status is is null meaning blank attribute. That is what I want to achieve for this query. But I have problem of fetching the is null value. When I run my query the row that has is null status value did not get displayed in my desired output.
This is what I have tried
SELECT name,file, status FROM tbl_geq where file = 'no' AND (status NOT LIKE 'pending-update');
When I run this query I got this output
| name | file | status |
-----------------------------
| willy | no | pending |
| wiki | no | pending |
-----------------------------
How can I fix my query and achieve this output?
| name | file | status |
-----------------------------
| willy | no | pending |
| ash | no | |
| wiki | no | pending |
| wilma | no | |
-----------------------------
You must handle the NULL values explicitly:
AND (status IS NULL OR status <> 'pending-update')
An alternate (but less readable imo) is:
AND NOT (status <=> 'pending-update')
Keep in mind that SQL uses three-valued logic... a condition could be true, false or unknown. All comparisons involving NULL result in "unknown" which is not the same as false.

MySQL UPDATE | How to update filepath URI that saved in database

I have a table album that contains about 1000 rows. I want to update all rows.
Table album have a column named path. See full table structure below.
+---------------------------------------------------------------------------------------------+
| id | name | path |
+---------------------------------------------------------------------------------------------+
| 1 | Believe | Believe |
+---------+-----------+-----------------------------------------------------------------------+
| 2 | A Promise | A Promise |
+---------+----------+------------------------------------------------------------------------+
| 3 | Forever | Forever |
+---------------------------------------------------------------------------------------------+
I want to update path here. Want to add album in path for SEO friendly URLs. table should look like this for that goal.
+--------------------------------------------------------------------------------------------------+
| id | name | path |
+--------------------------------------------------------------------------------------------------+
| 1 | Believe | Believe |
+---------+-----------+----------------------------------------------------------------------------+
| 2 | A Promise | A Promise|
+---------+----------+-----------------------------------------------------------------------------+
| 3 | Forever | Forever |
+--------------------------------------------------------------------------------------------------+
I can't figure out how to use LIKE here, what to insert between % %. Please help me. Thanks in advance.

Mysql table does not accept any update request

I am using Server version: 5.6.27-log MySQL Community Server (GPL) and I have a problem with a table.
I tried to update some fields with a GUI software, but when I came back to the command line, the lines I tried to update where not updated.
I tried to see if the table was locked using SHOW OPEN TABLES as stated in various other questions. But my table does not appear to be locked:
+--------------------+-------------------------------------------------+--------+-------------+
| Database | Table | In_use | Name_locked |
+--------------------+-------------------------------------------------+--------+-------------+
| arcdev | SCHEDULED_COMMAND | 0 | 0 |
And as soon as I try to make an update like:
UPDATE SCHEDULED_COMMAND SET field = 1;
The server just keeps loading and nothing happen. I tried on other tables and everything worked just fine.
I also tried some DELETE requests and even a DROP TABLE and nothing work so far...
What am I missing?
Thank you for your precious help!
EDIT: Here is the result of the SHOW PROCESSLIST command while a request is hanging:
+--------+----------+---------------------------------------+-----------+---------+------+----------+-------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+--------+----------+---------------------------------------+-----------+---------+------+----------+-------------------------------+
| 282588 | rdsadmin | localhost:17966 | mysql | Sleep | 2 | | NULL |
| 534575 | arc | XXXXXX:49376 | arcdev | Sleep | 17 | | NULL |
| 534579 | arc | XXXXXX:49443 | arcdev | Query | 0 | init | SHOW PROCESSLIST |
| 534659 | arc | XXXXXX:49836 | arcdev | Query | 14 | updating | DELETE FROM SCHEDULED_COMMAND |
+--------+----------+---------------------------------------+-----------+---------+------+----------+-------------------------------+

MySql Event is not working

I have got this mysql data structure
| create_t | delete_t |
| 1479643496 | 1479643616 |
| 1479643496 | 1479643616 |
| 1479643637 | 1479643757 |
create_t and delete_t are both BigInt
And i have created an event like this
CREATE EVENT assaassas
ON SCHEDULE EVERY 50 SECOND
DO
DELETE FROM Test WHERE delete_time<='$date->getTimestamp()'"
But it is fruitless.