added containers
This commit is contained in:
parent
6ca1c00b76
commit
58618259a5
3 changed files with 81 additions and 9 deletions
25
app/Container.php
Normal file
25
app/Container.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Container extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'cid'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [];
|
||||
}
|
41
app/Http/Controllers/ContainerController.php
Normal file
41
app/Http/Controllers/ContainerController.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Container;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ContainerController extends Controller
|
||||
{
|
||||
|
||||
public function showAllContainers()
|
||||
{
|
||||
return response()->json(Container::all());
|
||||
}
|
||||
|
||||
public function showOneContainer($id)
|
||||
{
|
||||
return response()->json(Container::find($id));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$container = Container::create($request->all());
|
||||
|
||||
return response()->json($container, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$container = Container::findOrFail($id);
|
||||
$container->update($request->all());
|
||||
|
||||
return response()->json($container, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Container::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue