Initial api service;
Clean code;
This commit is contained in:
42
app/Http/Controllers/Api/WordsController.php
Normal file
42
app/Http/Controllers/Api/WordsController.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Word;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WordsController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth:sanctum');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$words = Word::all();
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'words' => $words
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Word $word)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'words' => $word
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user