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',
|
2021-08-14 13:05:11 +00:00
|
|
|
'name' => 'required|min:4|max:35|regex:/^[a-zA-Z-_~]{4,}$/|unique:echoareas,name,'.($o->exists ? $o->id : 0),
|
2021-08-11 13:45:30 +00:00
|
|
|
'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('echoarea.addedit')
|
|
|
|
->with('o',$o);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function home()
|
|
|
|
{
|
|
|
|
return view('echoarea.home');
|
|
|
|
}
|
|
|
|
}
|