You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
1.8 KiB
85 lines
1.8 KiB
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Instruction;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class InstructionController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index(): JsonResponse
|
|
{
|
|
|
|
return response()->json();
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request): JsonResponse
|
|
{
|
|
$request->validate([
|
|
'file' => 'required|file|mimes:json',
|
|
'frameworkID' => 'required|exists:frameworks,id',
|
|
'pageID' => 'required|exists:pages,id',
|
|
]);
|
|
|
|
$file = $request->file('file');
|
|
$path = $file->store('instructions', 'public');
|
|
|
|
$instruction = Instruction::create([
|
|
'page_id' => $request->pageID,
|
|
'framework_id' => $request->frameworkID,
|
|
'file_path' => $path,
|
|
]);
|
|
|
|
return response()->json([
|
|
'message' => 'Instruction saved successfully',
|
|
'instruction' => $instruction,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(Instruction $instruction)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(Instruction $instruction)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, Instruction $instruction)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(Instruction $instruction)
|
|
{
|
|
//
|
|
}
|
|
}
|