my first commit
This commit is contained in:
41
app/Http/Controllers/CategoriesController.php
Normal file
41
app/Http/Controllers/CategoriesController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Categories;
|
||||
use SebastianBergmann\CodeCoverage\Report\Xml\Project;
|
||||
|
||||
class CategoriesController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
return response()->json(Categories::all());
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$category = Categories::find($id);
|
||||
if ($category) {
|
||||
return response()->json($category->toArray());
|
||||
} else {
|
||||
return response()->json(['message' => 'Категория не найдена'], 404);
|
||||
}
|
||||
|
||||
}
|
||||
public function create(Request $request)
|
||||
{
|
||||
$name = $request->get(key:'name');
|
||||
$description = $request->get(key:'description');
|
||||
$creatoruserId = 1;
|
||||
|
||||
$Services = new Services();
|
||||
$Services->name = $name;
|
||||
$Services->description = $description;
|
||||
$Services->category_id = $category_id;
|
||||
$Services->save();
|
||||
|
||||
return response()->json($Services->tojson());
|
||||
}
|
||||
}
|
||||
8
app/Http/Controllers/Controller.php
Normal file
8
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
10
app/Http/Controllers/ServicesController.php
Normal file
10
app/Http/Controllers/ServicesController.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ServicesController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
Reference in New Issue
Block a user