Skip to content

Commit 1b4d93b

Browse files
committed
get all subject api
1 parent 982405a commit 1b4d93b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Diff for: app/Http/Controllers/SubjectsController.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use App\Subject;
7+
8+
class SubjectsController extends Controller
9+
{
10+
public function getAll() {
11+
return Subject::all();
12+
}
13+
}

Diff for: app/Subject.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Subject extends Model
8+
{
9+
protected $table = 'subject';
10+
11+
protected $fillable = [
12+
'subjectName', 'marks',
13+
];
14+
}

Diff for: routes/api.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
});
1919

2020
Route::get('users', 'TestController@index');
21+
22+
Route::get('subjects', 'SubjectsController@getAll');

0 commit comments

Comments
 (0)