my first commit

This commit is contained in:
root
2025-11-19 15:18:35 +00:00
commit 9c85a9d0c8
97 changed files with 13637 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers;
use App\Models\Candidate;
use Illuminate\Http\Request;
class CandidatesController extends Controller
{
public function index()
{
return response()->json(Candidate::all()->toJSON());
}
public function show($id)
{
$candidate = Candidate::friend($id);
if ($candidate) {
return response()->json($candidate->toArray());
} else {
return response()->json(['message' => 'Кандидант не найден'], 404);
}
}
public function create(Request $request)
{
$title = $request->get(key:'title');
$description = $request->get(key:'description');
$creatorUser = 1;
$candidate = new Candidate();
$candidate->title = $title;
$candidate->description =$description;
$candidate->craetor_user_id =$creatorUser;
$candidate->save();
return response()->json($candidate->toJson());
}
}