Enable echomail subscription by any of a systems address
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -275,6 +275,17 @@ class SystemController extends Controller
|
||||
: redirect()->to('user/system/register');
|
||||
}
|
||||
|
||||
public function api_address(Request $request,System $o): Collection
|
||||
{
|
||||
return Address::select(['addresses.id','addresses.zone_id','region_id','host_id','node_id'])
|
||||
->leftjoin('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->where('addresses.system_id',$o->id)
|
||||
->where('zones.domain_id',$request->domain_id)
|
||||
->FTNorder()
|
||||
->get()
|
||||
->map(function($item) { return ['id'=>$item->id,'value'=>$item->ftn3d]; });
|
||||
}
|
||||
|
||||
/**
|
||||
* Systems with no owners
|
||||
*/
|
||||
@@ -335,7 +346,7 @@ class SystemController extends Controller
|
||||
*/
|
||||
public function echoareas(Request $request,System $o)
|
||||
{
|
||||
$ao = $o->addresses->filter(function($item) use ($request) { return $item->zone->domain_id == $request->domain_id; })->first();
|
||||
$ao = $o->addresses->firstWhere('id',$request->address_id);
|
||||
|
||||
if (($request->method() == 'POST') && $request->post()) {
|
||||
session()->flash('accordion','echoarea');
|
||||
@@ -344,13 +355,13 @@ class SystemController extends Controller
|
||||
if (! $ao->session('sespass'))
|
||||
return redirect()->back()->withErrors('System doesnt belong to this network');
|
||||
|
||||
$ao->echoareas()->syncWithPivotValues($request->id,['subscribed'=>Carbon::now()]);
|
||||
$ao->echoareas()->syncWithPivotValues($request->get('id',[]),['subscribed'=>Carbon::now()]);
|
||||
|
||||
return redirect()->back()->with('success','Echoareas updated');;
|
||||
}
|
||||
|
||||
$eo = Echoarea::active()
|
||||
->where('domain_id',$request->domain_id)
|
||||
->where('domain_id',$ao->zone->domain_id)
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
|
Reference in New Issue
Block a user