clrghouz/app/Http/Controllers/FileareaController.php
2021-08-11 23:45:49 +10:00

48 lines
1019 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Filearea;
use Illuminate\Http\Request;
class FileareaController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Add or edit a echoarea
*/
public function add_edit(Request $request,Filearea $o)
{
if ($request->post()) {
$this->authorize('admin',$o);
$request->validate([
// http://ftsc.org/docs/old/fsp-1028.002
'domain_id' => 'required|exists:domains,id',
'name' => 'required|max:35|regex:/^[a-zA-Z-_~]{1,8}$/|unique:echoareas,name,'.($o->exists ? $o->id : 0),
'description' => 'required',
'active' => 'required|boolean',
'public' => 'required|boolean',
]);
foreach (['name','description','active','public','notes','domain_id'] as $key)
$o->{$key} = $request->post($key);
$o->save();
return redirect()->action([self::class,'home']);
}
return view('filearea.addedit')
->with('o',$o);
}
public function home()
{
return view('filearea.home');
}
}