41 lines
801 B
PHP
41 lines
801 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\File;
|
|
use Illuminate\Http\Request;
|
|
|
|
class FileController extends Controller
|
|
{
|
|
|
|
public function showAllFiles()
|
|
{
|
|
return response()->json(File::all());
|
|
}
|
|
|
|
public function showOneFile($id)
|
|
{
|
|
return response()->json(File::find($id));
|
|
}
|
|
|
|
public function create(Request $request)
|
|
{
|
|
$File = File::create($request->all());
|
|
|
|
return response()->json($File, 201);
|
|
}
|
|
|
|
public function update($id, Request $request)
|
|
{
|
|
$File = File::findOrFail($id);
|
|
$File->update($request->all());
|
|
|
|
return response()->json($File, 200);
|
|
}
|
|
|
|
public function delete($id)
|
|
{
|
|
File::findOrFail($id)->delete();
|
|
return response('Deleted Successfully', 200);
|
|
}
|
|
}
|