38 lines
970 B
PHP
38 lines
970 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\SportCourses;
|
|
use App\Models\Category;
|
|
use App\Models\Product;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
class SportsCoursesController extends Controller
|
|
{
|
|
|
|
//Создание наименования курса
|
|
public function CreateSportCourses(Request $request)
|
|
{
|
|
$error = Validator::make($request->all(), [
|
|
'name' => 'required',
|
|
'description' => 'required',
|
|
]);//1024
|
|
if ($error->fails()) {
|
|
return response(['error' => ['code' => 400, 'message' => 'Validation error', 'errors' => $error->errors()]], 400);
|
|
}
|
|
else{
|
|
SportCourses::create([
|
|
'name' => $request->name,
|
|
'description' => $request->description
|
|
]);
|
|
return response(['Новый курс создан'], 200);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|