2021-08-11 13:45:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\Filearea;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class FileareaController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Add or edit a echoarea
|
|
|
|
*/
|
|
|
|
public function add_edit(Request $request,Filearea $o)
|
|
|
|
{
|
|
|
|
if ($request->post()) {
|
|
|
|
$this->authorize('admin',$o);
|
|
|
|
|
|
|
|
$request->validate([
|
|
|
|
'domain_id' => 'required|exists:domains,id',
|
2021-08-14 13:52:39 +00:00
|
|
|
'name' => 'required|min:4|max:35|regex:/^[a-zA-Z-_~]{4,}$/|unique:fileareas,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-07-29 03:17:36 +00:00
|
|
|
'nodelist' => 'nullable|string|max:12',
|
|
|
|
'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-07-28 03:22:39 +00:00
|
|
|
foreach (['name','description','active','show','notes','domain_id'] 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();
|
|
|
|
|
2022-11-04 06:20:22 +00:00
|
|
|
if ($request->post('nodelist')) {
|
|
|
|
$o->domain->nodelist_filename = $request->post('nodelist');
|
|
|
|
$o->domain->nodelist_filearea_id = $o->id;
|
|
|
|
$o->domain->save();
|
|
|
|
}
|
|
|
|
|
2021-08-11 13:45:30 +00:00
|
|
|
return redirect()->action([self::class,'home']);
|
|
|
|
}
|
|
|
|
|
|
|
|
return view('filearea.addedit')
|
|
|
|
->with('o',$o);
|
|
|
|
}
|
|
|
|
}
|