/** * Run the database seeds. * * @return void */ public function run() { $networks = [['name' => 'viettel'], ['name' => 'vinaphone'], ['name' => 'mobifone']]; foreach ($networks as $network) { Network::create($network); } }
/** * Return create tag view * * @return \Illuminate\View\View */ public function create($team, $feed_id) { $team = Team::where('slug', '=', $team)->with('feeds')->first(); $feed = Feed::with('tags.network')->where('id', '=', $feed_id)->first(); $networks = Network::all(); return view('admin.tags.create', ['feed' => $feed, 'team' => $team, 'networks' => $networks]); }
/** * publishs the tracking of terms with supervisor and phirehose * * @return \Illuminate\View\View */ public function publish($team, $network_id) { $team = Team::where('slug', '=', $team)->first(); $network = Network::find($network_id); $network = $network->title; $keys = json_decode($team->{$network}); //Create GuzzleHttp client $guzzleClient = new \GuzzleHttp\Client(); // Pass the url and the guzzle client to the XmlRpc Client $client = new Client('http://localhost:9001/RPC2', new HttpAdapterTransport(new Guzzle6HttpAdapter($guzzleClient))); // Generate XMLRpc and Supervisor Instances $connector = new XmlRpc($client); $supervisor = new Supervisor($connector); // setup flysystem $adapter = new Local('/etc/supervisor/conf.d/'); $filesystem = new Filesystem($adapter); // create new supervisor files $writer = new File($filesystem, 'test.conf'); $configuration = new Configuration(); $section = $this->generateNewProcess($keys, $team->id); $configuration->addSection($section); $writer->write($configuration); // restart supervisor $supervisor->restart(); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['name' => 'required|min:3']); $network = $request->all(); $network['user_id'] = Auth::user()->id; Network::create($network); return redirect(route('network.index')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $trap = Traps::findOrFail($id); $trap['network'] = array_add(Network::lists('name', 'id'), 0, 'Default'); if ($trap->user_id != Auth::user()->id) { return redirect(route('network.index')); } $notifications = Notifications::latest()->get(); return view('traps.edit')->with('trap', $trap)->with('notifications', $notifications); }
/** * Return feeds view * * @return \Illuminate\View\View */ public function index($team) { $team = Team::where('slug', '=', $team)->with('feeds')->first(); $networks = Network::all(); return view('admin.feeds.index', ['team' => $team, 'networks' => $networks]); }