예제 #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::travel_company_staff()->get()->type != 1) {
         abort('404');
     }
     return $next($request);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $company_id = Auth::travel_company_staff()->get()->travel_company->id;
     $this->validate($request, ['country' => 'required', 'region' => 'required', 'city' => 'required', 'location' => 'required']);
     $request = array_add($request->all(), 'travel_company_id', $company_id);
     Station::create($request);
     return redirect()->route('company.stations.index');
 }
예제 #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::user()->get()) {
         return redirect()->route('welcome');
     } elseif (Auth::travel_company_staff()->get()) {
         return redirect()->route('company_login');
     }
     return $next($request);
 }
 /**
  * Log the user out of the application.
  *
  * @return \Illuminate\Http\Response
  */
 public function getCompanyLogout()
 {
     Auth::travel_company_staff()->logout();
     Session::flush();
     return redirect()->route('company_login');
 }
예제 #5
0
 public function profile_image(Request $request)
 {
     $travel_company = Auth::travel_company_staff()->get()->travel_company;
     $this->validate($request, ['terminal_images' => 'required']);
     $terminal_images = $request->terminal_images;
     $n_o_i = count($terminal_images);
     $destinationPath = null;
     if (App::environment() == 'local') {
         $destinationPath = base_path() . '/public/images/';
     } elseif (App::environment() == 'production') {
         $destinationPath = '/home/twokays/public_html/images/';
     }
     if (count($terminal_images) > 0) {
         for ($i = 0; $i < $n_o_i; $i++) {
             if ($terminal_images[$i]->isValid()) {
                 $img = $terminal_images[$i];
                 $file = $img;
                 $ext = $file->getClientOriginalExtension();
                 $destinationPath = $destinationPath;
                 $fileName = str_slug($travel_company->name) . '_image_' . $i . '.' . $ext;
                 $full_path = '/images/' . $fileName;
                 $file->move($destinationPath, $fileName);
                 // uploading file to given path
                 $tcl = TravelCompanyPicture::where('travel_company_id', $travel_company->id)->where('path', $full_path)->first();
                 if (!$tcl) {
                     TravelCompanyPicture::create(['path' => $full_path, 'travel_company_id' => $travel_company->id]);
                 } else {
                     $tcl->update(['path' => $full_path]);
                 }
             }
         }
     } else {
         return redirect()->back()->withErrors('Please Choose at least an image');
     }
     return redirect()->route('company_settings');
 }
 /**
  * Create a new filter instance.
  *
  * @param  Guard  $auth
  * @return void
  */
 public function __construct()
 {
     $this->auth = Auth::travel_company_staff();
 }
 /**
  * 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]);
 }