mirror of
https://github.com/kevin-DL/exercise_tracker_api.git
synced 2026-03-10 11:44:34 +00:00
Created exercises
- Added endpoint to retrieve the list of exercises
This commit is contained in:
39
app/Exercise.php
Normal file
39
app/Exercise.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Exercise extends Model
|
||||
{
|
||||
/**
|
||||
* The name of the exercise
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
18
app/Http/Controllers/ExerciseController.php
Normal file
18
app/Http/Controllers/ExerciseController.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Exercise;
|
||||
|
||||
class ExerciseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get the list of exercises
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index() {
|
||||
return response()->json(Exercise::all());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user