public function __construct(FreightPrice $freightprice, Truck $truck, Party $party, Station $station) { $this->truck = $truck->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account')); $this->party = $party->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account')); $this->station = $station->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account')); $this->freightprice = $freightprice->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $branche = new Station(); $branche->user_id = Auth::user()->id; $branche->airport_id = $request->airport; if ($branche->save()) { return response()->json(['success' => true, 'airport' => Airport::find($request->airport)]); } }
/** * Retrieve all Stations with their products * * @return \Illuminate\Database\Eloquent\Collection|static[] */ public function index() { return Station::with(['products' => function ($q) { $q->select('id'); $q->orderBy('sort'); }])->get(); }
public function run() { DB::table('stations')->delete(); $testUser = User::where('email', '*****@*****.**')->firstOrFail(); $stationOne = Station::create(array('title' => 'Romanian Station', 'address' => 'http://37.130.230.93:9092')); $stationTwo = Station::create(array('title' => 'Hungarian Station', 'address' => 'http://79.113.77.105:8000')); }
/** * @return \Illuminate\View\View */ public function dashboard() { $company_id = Auth::travel_company_staff()->get()->travel_company->id; $number_of_trips = Trip::whereraw('travel_company_id = ?', [$company_id])->count(); $number_of_stations = Station::whereraw('travel_company_id = ?', [$company_id])->count(); $number_of_paid_bookings = Booking::whereraw('travel_company_id = ? AND status = ?', [$company_id, 'paid'])->count(); $number_of_travel_bookings = Booking::whereraw('travel_company_id = ? AND status = ? AND updated_at > ?', [$company_id, 'paid', Carbon::today()])->count(); return view('companies.account.dashboard', ['number_of_trips' => $number_of_trips, 'number_of_stations' => $number_of_stations, 'number_of_paid_bookings' => $number_of_paid_bookings, 'number_of_travel_bookings' => $number_of_travel_bookings]); }
public function destroy(Request $request, $station_id, $aerometric_id) { $station = \App\Station::findOrFail($station_id); if (!$request->user()->isAdmin() && $station->user_id != $request->user()->id) { return abort(403); } $aerometric = \App\Aerometric::findOrFail($aerometric_id); $aerometric->delete(); return redirect()->to('backend/stations/' . $station->id . '/aerometrics'); }
public static function boot() { parent::boot(); Station::deleting(function ($station) { foreach ($station->aerometrics as $aerometric) { $aerometric->delete(); } $station->tags()->detach(); }); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $this->validate($request, ['name' => 'required|max:255']); $input = $request->all(); $input['company_id'] = Auth::user()->company_id; $input['user_id'] = Auth::user()->id; $input['account_year_id'] = session('account'); Station::create($input); flash()->success('Station Created Successfully !'); return redirect('station'); }
/** * Show the form for editing the specified resource. * * @param Station $station * * @param Trip $trip * * @internal param int $id * @return Response */ public function edit(Trip $trip) { $company = Auth::travel_company_staff()->get()->travel_company; $stations = Station::whereraw('travel_company_id = ?', [$company->id])->get(); return view('companies.trips.edit', ['stations' => $stations, 'trip' => $trip]); }
/** * @param $station_id * @return mixed */ public function genre($station_id) { return Station::findOrFail($station_id)->genre; }
/** * Remove the specified resource from storage. * * @param Station $station * * @throws \Exception * @internal param int $id * @return Response */ public function destroy(Station $station) { $station->delete(); return redirect()->route('company.stations.index'); }
public function index() { $stations = \App\Station::get(); return view('home.index', compact('stations')); }
public function postImport(Request $request, $id) { $station = \App\Station::findOrFail($id); if (!$request->user()->isAdmin() && $station->user_id != $request->user()->id) { return abort(403); } $this->validate($request, ['file' => 'required|mimes:txt|max:5000']); $file = request()->file('file'); $contents = file_get_contents($file->getPathname()); $data = []; if ($file->getClientOriginalExtension() == 'csv') { $lines = explode("\r\n", $contents); $array = array_map("str_getcsv", $lines); $header = array_shift($array); foreach ($array as $v) { $data[] = array_combine($header, $v); } } else { if ($file->getClientOriginalExtension() == 'json') { $data = json_decode($contents, true); } } foreach ($data as $d) { $aerometric = new \App\Aerometric(); $aerometric->station_id = $station->id; foreach (array_keys(config('aerometrics.properties')) as $property) { $aerometric->{$property} = array_get($d, $property, '0.0'); } $aerometric->created_at = $aerometric->updated_at = array_get($d, 'created_at', new \DateTime('now')); $aerometric->save(); } return redirect('backend/stations/' . $station->id); }
public function run() { $station = Station::create(['name' => 'Pizza Oven', 'color' => 'D4B46A', 'type_id' => 1]); $product = Product::find(6); $station->products()->save($product); }
public function create(Request $request) { $station_id = $request->input('station_id'); $station = Station::find($station_id); return view('admin.station_data.create', array('title' => 'Admin: Station Data Create - ' . $station->name . ' (Event: ' . $station->event->name . ')', 'station_id' => $station_id)); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $currentUser = Auth::user(); $stations = Station::where('email', $currentUser->getEmail())->get(); return Response::json(array('stations' => $stations)); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(FlightThreadCreateRequest $request) { $departure_time = strtotime($request->departure_time); $arrival_time = Carbon::createFromTimestamp($departure_time)->addHours(2)->addMinutes(0); $departure_time = Carbon::createFromTimestamp($departure_time); $flightThread = new FlightThread(); $flightThread->fill($request->all()); $flightThread->slug = str_slug($request->flight_number); $flightThread->departure_airport_id = Station::find($request->departure_station_id)->airport_id; $flightThread->arrival_airport_id = Station::find($request->arrival_station_id)->airport_id; $flightThread->arrival_time = $arrival_time; $flightThread->user_id = Auth::user()->id; $flightThread->save(); if (is_array($request->days)) { foreach ($request->days as $day) { $flightday = new FlightDay(); $flightday->flight_thread_id = $flightThread->id; $flightday->offset = $request->departure_offset[$day]; $flightday->day = $day; $flightday->departure_time = $departure_time->addMinutes($request->departure_offset[$day]); $flightday->arrival_time = $arrival_time->addMinutes($request->departure_offset[$day]); $flightday->departure_airport_id = Station::find($request->departure_station_id)->airport_id; $flightday->arrival_airport_id = Station::find($request->arrival_station_id)->airport_id; $flightday->departure_station_id = $request->departure_station_id; $flightday->arrival_station_id = $request->arrival_station_id; $flightday->save(); } } return redirect()->route('flightOverview')->with('success', 'Flug wurde eingeplant'); //Hinflug /*$flightThread = new FlightThread; $flightThread->fill($request->all()); $flightThread->user_id = Auth::user()->id; $flightThread->slug = str_slug($request->flight_number); $flightThread->save(); //Zurückflug $flightThread = new FlightThread; $flightThread->aircraft_id = $request->aircraft_id; $flightThread->flight_number = $request->flight_number_back; $flightThread->departure_airport_id = $request->arrival_airport_id; $flightThread->arrival_airport_id = $request->departure_airport_id; $flightThread->user_id = Auth::user()->id; $flightThread->slug = str_slug($request->flight_number_back); $flightThread->save();*/ /*return redirect()->route('flightOverview')->with('success', 'Flug wurde erstellt');*/ /*$flight = new Flight; $flight->flight_thread_id = $flightThread->id; $flight->departure_time = Carbon::createFromFormat('Y-m-d G:i',$request->departure_day.' '.$request->departure_time); $flight->arrival_time = Carbon::createFromFormat('Y-m-d G:i',$request->departure_day.' '.$request->departure_time)->addHours(24)->second(0); $flight->user_id = Auth::user()->id; if($flight->save()){ return redirect()->route('flightOverview')->with('success', 'Flug wurde erstellt'); }*/ }
/** * Remove the specified resource from storage. * * @param int Station $station * @return \Illuminate\Http\Response */ public function destroy(Station $station) { // $station->delete(); return Redirect::route('stations.index')->with('message', 'Station deleted.'); }
/** * @return \Illuminate\View\View */ public function all_stations() { $stations = Station::all(); return view('pages.all_stations', ['stations' => $stations]); }
/** * Execute the console command. * * @return mixed */ public function handle() { Station::reindex(); $this->info('All done...'); }
public function destroy($station_id) { $station = Station::find($station_id); $station->delete(); return redirect()->back(); }