my first commit
This commit is contained in:
29
app/Http/Controllers/ChatsController.php
Normal file
29
app/Http/Controllers/ChatsController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Chat;
|
||||
|
||||
class ChatsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
return response()->json(Chat::all()->toJson());
|
||||
}
|
||||
public function show(int $id){
|
||||
return response()->json(Chat::find($id)->toJson());
|
||||
}
|
||||
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$title = $request->get('title');
|
||||
|
||||
$chats = new Chat();
|
||||
$chats->title = $title;
|
||||
|
||||
$chats->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user