2021-08-11 13:45:30 +00:00
|
|
|
<?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',
|
2023-09-10 12:48:12 +00:00
|
|
|
'name' => 'required|min:4|max:35|regex:/^[a-zA-Z0-9\-_~]{4,}$/|unique:echoareas,name,'.($o->exists ? $o->id : 0),
|
2021-08-11 13:45:30 +00:00
|
|
|
'description' => 'required',
|
|
|
|
'active' => 'required|boolean',
|
2023-07-28 03:22:39 +00:00
|
|
|
'show' => 'required|boolean',
|
2023-09-12 07:20:09 +00:00
|
|
|
'automsgs' => 'required|boolean',
|
2023-07-29 03:17:36 +00:00
|
|
|
'sec_read' => 'required|integer|min:0|max:7',
|
|
|
|
'sec_write' => 'required|integer|min:0|max:7',
|
2021-08-11 13:45:30 +00:00
|
|
|
]);
|
|
|
|
|
2023-09-12 07:20:09 +00:00
|
|
|
foreach (['name','description','active','show','notes','domain_id','automsgs'] as $key)
|
2021-08-11 13:45:30 +00:00
|
|
|
$o->{$key} = $request->post($key);
|
|
|
|
|
2023-07-29 03:17:36 +00:00
|
|
|
$o->setRead($request->post('sec_read'));
|
|
|
|
$o->setWrite($request->post('sec_write'));
|
|
|
|
|
2021-08-11 13:45:30 +00:00
|
|
|
$o->save();
|
|
|
|
|
2023-10-05 12:28:18 +00:00
|
|
|
return redirect()->to('echoarea');
|
2021-08-11 13:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return view('echoarea.addedit')
|
|
|
|
->with('o',$o);
|
|
|
|
}
|
|
|
|
}
|