clrghouz/app/Http/Controllers/EchoareaController.php
Deon George e802fe5030
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 33s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m33s
Create Docker Image / Final Docker Image Manifest (push) Successful in 8s
Echoarea tag can have a period
2024-11-08 18:40:57 +11:00

44 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Echoarea;
class EchoareaController extends Controller
{
/**
* Add or edit a echoarea
*/
public function add_edit(Request $request,Echoarea $o)
{
if ($request->post()) {
$this->authorize('admin',$o);
$request->validate([
'domain_id' => 'required|exists:domains,id',
'name' => 'required|min:4|max:35|regex:/^[a-zA-Z0-9\-_~.]{4,}$/|unique:echoareas,name,'.($o->exists ? $o->id : 0),
'description' => 'required',
'active' => 'required|boolean',
'show' => 'required|boolean',
'automsgs' => 'required|boolean',
'sec_read' => 'required|integer|min:0|max:7',
'sec_write' => 'required|integer|min:0|max:7',
]);
foreach (['name','description','active','show','notes','domain_id','automsgs'] as $key)
$o->{$key} = $request->post($key);
$o->setRead($request->post('sec_read'));
$o->setWrite($request->post('sec_write'));
$o->save();
return redirect()->to('echoarea');
}
return view('echoarea.addedit')
->with('o',$o);
}
}