add File api endpoints
This commit is contained in:
parent
17e859b9ba
commit
d815f64dc8
4 changed files with 50 additions and 18 deletions
|
@ -16,6 +16,8 @@ class File extends Model
|
|||
'hash', 'iid'
|
||||
];
|
||||
|
||||
protected $primaryKey = 'hash';
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class ExampleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
}
|
41
app/Http/Controllers/FileController.php
Normal file
41
app/Http/Controllers/FileController.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue