Enabled moving address, minor CSS fixes
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Models\{Address,System,Zone};
|
||||
use App\Rules\{FidoInteger,TwoByteInteger};
|
||||
@@ -312,6 +313,47 @@ class SystemController extends Controller
|
||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Move address to another system
|
||||
*
|
||||
* @param Request $request
|
||||
* @param System $so
|
||||
* @param Address $o
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function mov_address(Request $request,System $so,Address $o)
|
||||
{
|
||||
// Quick check that this address belongs to this system
|
||||
if ($so->addresses->search(function($item) use ($o) { return $item->id == $o->id; }) === FALSE)
|
||||
abort(404);
|
||||
|
||||
if ($request->post()) {
|
||||
$this->authorize('admin',$o);
|
||||
|
||||
$validated = $request->validate([
|
||||
'system_id' => 'required|exists:systems,id',
|
||||
'remove' => 'nullable|boolean',
|
||||
'remsess' => 'nullable|boolean|exclude_if:remove,1',
|
||||
]);
|
||||
|
||||
$o->system_id = $validated['system_id'];
|
||||
$o->save();
|
||||
|
||||
if (Arr::get($validated,'remove')) {
|
||||
$so->sessions()->detach($o->zone);
|
||||
$so->delete();
|
||||
|
||||
} elseif (Arr::get($validated,'remsess')) {
|
||||
$so->sessions()->detach($o->zone);
|
||||
}
|
||||
|
||||
return redirect()->to('ftn/system/addedit/'.$validated['system_id']);
|
||||
}
|
||||
|
||||
return view('system.moveaddr')
|
||||
->with('o',$o);
|
||||
}
|
||||
|
||||
public function ours()
|
||||
{
|
||||
return view('system.ours');
|
||||
|
Reference in New Issue
Block a user