/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateBookRequest $request)
 {
     $user = \Auth::User();
     if (!$user) {
         return view('auth.login')->withErrors('You are not loged in, please loged in !');
     }
     $book = $request->bookFillData();
     $book['user_id'] = $user->id;
     $book['published_at'] = Carbon::parse($request->get('published_at'))->format('Y-m-d');
     $fileSizeValidation = \Config::get('library.image_file_size');
     $newBook = Book::create($book);
     $newBook->syncAuthors($request->get('authors'));
     $this->manager->createDirectory($newBook->id);
     $file = $_FILES['image'];
     if ($file['size'] > 0) {
         // Additional image validation
         if (!starts_with($file['type'], 'image/')) {
             return Redirect::action('BookController@create')->withErrors('Invalid file format, please use image !');
         }
         $fileSize = $file['size'] / 1024;
         if ($fileSize > $fileSizeValidation) {
             return Redirect::action('BookController@create')->withErrors('The image may not be greater than ' . $fileSizeValidation . ' kilobytes. ');
         }
         $img = Image::make($_FILES['image']['tmp_name']);
         $img->resize(140, 140);
         $img->save('.' . \Config::get('library.uploads.webpath') . DIRECTORY_SEPARATOR . $newBook->id . '/cover.jpg');
     }
     return redirect::action('BookController@index')->withSuccess("The book with title '{$newBook->title}' was created.");
 }
Example #2
0
 public function actualizar(Request $request)
 {
     if ($request->ajax()) {
         $email = $request['email'];
         $password = $request['password'];
         $new_password = $request['new_password'];
         $user = \Auth::User();
         $updated = false;
         if (Hash::check($password, $user->password)) {
             $aux = \App\User::find($email);
             if ($aux == null || $aux->email == $user->email) {
                 $user->email = $email;
                 $updated = true;
             } else {
                 return -2;
             }
             if ($new_password != '') {
                 $user->password = bcrypt($new_password);
             }
             $user->save();
             return 1;
         } else {
             return -1;
         }
     }
 }
Example #3
0
 public function __construct()
 {
     $objUser = \Auth::User() ?: \App\User::GetGuestAccount();
     View::share('CareerCount', \App\Career::where('status', \App\Career::STATUS_ENABLED)->count());
     View::share('PageTitle', 'Welcome');
     View::share('objUser', $objUser);
 }
Example #4
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $name = $request->input('name');
     $artist = $request->input('artist');
     $type = 1;
     $view;
     if (\Auth::check()) {
         if (\Auth::User()->roll == "Administrador") {
             $view = 'songs.index';
         } else {
             if (\Auth::User()->roll == "Cliente") {
                 $view = 'songs.songs_user';
             }
         }
         if ($name == null && $artist == null) {
             $songs = Song::getsongs();
             return view($view, compact('songs'));
         } else {
             if ($name != null && $artist == null) {
                 $songs = \App\Models\Song::search_by_song($name, $type);
                 return view($view, compact('songs'));
             } else {
                 if ($name == null && $artist != null) {
                     $songs = \App\Models\Song::search_by_singer($artist);
                     return view($view, compact('songs'));
                 } else {
                     $songs = \App\Models\Song::search_by_singer_song($name, $artist);
                     return view($view, compact('songs'));
                 }
             }
         }
     } else {
         return view('auth.login');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\EmployeeRequest $request)
 {
     //
     $data = $request->except('_token');
     $data['user_id'] = \Auth::User()->id;
     $employee = new Employee();
     $employee->create($data);
     return back();
 }
Example #6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $traslado = new Traslados($request->all());
     \Auth::User()->traslados()->save($traslado);
     foreach ($data['animales'] as $i => $animal) {
         $traslado->animales()->attach($animal);
     }
     return redirect()->route('traslados.show', $traslado->id);
 }
Example #7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $compras = new Compras($request->all());
     \Auth::User()->compras()->save($compras);
     foreach ($data['insumos'] as $i => $insumo) {
         \DB::table('compras_insumos')->insertGetId(array('compra_id' => $compras->id, 'insumo_id' => $insumo['insumo_id'], 'precio' => $insumo['precio'], 'cantidad' => $insumo['cantidad'], 'almacen_id' => $insumo['almacen']));
     }
     return redirect()->route('compras.show', $compras->id);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $compras = new Compras($request->all());
     \Auth::User()->comprasinsumos()->save($compras);
     foreach ($data['insumos'] as $i => $insumo) {
         $compras->insumos()->attach($insumo);
     }
     return redirect()->route('comprasinsumos.show', $compras->id);
 }
 public function index()
 {
     $ranks = \App\Ranking::all();
     foreach ($ranks as $rank) {
         if ($ranks->count() >= $rank->id * 2 * 2 + 3) {
             $rank->slot_exit = 1;
             $rank->save();
         }
     }
     return view('dashboard.admin.rank')->with(['ranks' => $ranks, 'user' => \Auth::User()]);
 }
Example #10
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $servicio = new Servicios($request->all());
     \Auth::User()->servicios()->save($servicio);
     foreach ($data['animales'] as $d) {
         $id = \DB::table('servicios_potreros')->insertGetId(array('animal_id' => $d['animal_id'], 'potrero_origen_id' => $d['potrero_origen_id'], 'servicio_id' => $servicio->id));
         \DB::table('animales')->where('id', $d['animal_id'])->update(['potrero_id' => $servicio['potrero_id']]);
     }
     return redirect()->route('servicios.show', $servicio->id);
 }
Example #11
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $movimiento = new Movimientos($request->all());
     \Auth::User()->movimientos()->save($movimiento);
     //print_r($data); die();
     foreach ($data['pivot'] as $d) {
         $id = \DB::table('movimientos_animales')->insertGetId(array('animal_id' => $d['animal_id'], 'potrero_origen_id' => $d['potrero_origen_id'], 'potrero_destino_id' => $d['potrero_destino_id'], 'movimiento_id' => $movimiento->id));
         \DB::table('animales')->where('id', $d['animal_id'])->update(['potrero_id' => $d['potrero_destino_id']]);
     }
     return redirect()->route('movimientos.show', $movimiento->id);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Requests\VaccineDoseRequest $request
  * @return Response
  */
 public function store(Requests\VaccineDoseRequest $request)
 {
     $input = $request->all();
     $vaccine_id = $input['vaccine_id'];
     for ($i = 0; $i < count($input['dose_no']); $i++) {
         $data['dose_vaccine_id'] = $vaccine_id;
         $data['dose_vaccine_dose_no'] = $input['dose_no'][$i];
         $data['years'] = $input['years'][$i];
         $data['months'] = $input['months'][$i];
         $data['days'] = $input['days'][$i];
         $data['dose_interval'] = $input['years'][$i] * 365 + $input['months'][$i] * 30 + $input['days'][$i];
         $data['created_by'] = \Auth::User()->id;
         $data['updated_by'] = \Auth::User()->id;
         $this->vaccineDose->create($data);
     }
     return redirect('vaccines')->with('message', 'Vaccine dose interval is assigned.');
 }
 public function create()
 {
     $num_slots = \Input::get('num_slots');
     $check = \Auth::User()->name . '' . Carbon::now();
     for ($i = 0; $i < $num_slots; $i++) {
         $slot = new \App\Slot();
         $slot->slot_code = bcrypt($check);
         $slot->slot_rank = 0;
         $slot->user_id = \Auth::User()->id;
         $slot->save();
         $status = \App\Status::find(2);
         $status->slots()->attach($slot);
     }
     $user = \Auth::User();
     $name = $user->name;
     $slots = $user->slots()->get();
     return view('dashboard.user.profile')->with(['slots' => $slots, 'name' => $name, 'num_slots' => $num_slots]);
 }
 /**
  * get notification
  *
  * default => the newset 10
  *
  * @param Request $request
  * @return Response
  */
 protected function show(Request $request)
 {
     $user = \Auth::User();
     if ($this->vaild_data_format($request->all(), ['range', 'item_id']) === true) {
         $item_id = $request->get("item_id");
         $range = $request->get("range");
         if ($range > 0) {
             $notis = $this->notificationRepository->getNotificationBack($user->stu_id, $item_id, $range);
         } else {
             $notis = $this->notificationRepository->getNotificationFront($user->stu_id, $item_id, $range * -1);
         }
     } else {
         $notis = $this->notificationRepository->getLatest10Notification($user->stu_id);
     }
     $this->responseData['status'] = "success";
     $this->responseData['data'] = NotificationPresenter::db2api($notis->toArray());
     $this->responseCode = 200;
     return $this->send_response();
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     if (\Auth::user()) {
         $order = \Auth::User()->orders();
         $ids = null;
         if ($order) {
             $orders = Orders::where('cust_id', \Auth::User()->id)->get();
         }
         $orders = Orders::where('cust_id', \Auth::User()->id)->where('order_id', $id)->get();
         $i = 0;
         foreach ($orders as $order) {
             $order['p_name'] = Products::where('id', $order->product_id)->value('p_name');
             $order['price'] = Products::where('id', $order->product_id)->value('price');
             $ids[$order['product_id']] = $order['product_id'];
         }
         return view('pages.order', compact('orders'), compact('ids'));
     } else {
         return redirect('auth/login');
     }
 }
Example #16
0
 /**
  * Show the application dashboard to the user, including suggestions to the user.
  *
  * @return Response
  */
 public function index()
 {
     $user = User::where('id', \Auth::id())->with('placesWanted')->with('events')->first();
     if ($user->placesWanted) {
         $event_ids = EventPlace::select('event_id')->whereNotIn('event_id', $user->events->lists('id'))->whereIn('place_id', $user->placesWanted->lists('id'))->orderBy(\DB::raw('rand()'))->distinct()->take(6)->get()->lists('event_id')->toArray();
         if (sizeof($event_ids) < 6) {
             $placeStateWanted = Place::select('id')->whereIn('state', $user->placesWanted->lists('state'))->get();
             $event_ids = array_merge($event_ids, EventPlace::select('event_id')->whereNotIn('event_id', $user->events->lists('id'))->whereIn('place_id', $placeStateWanted->lists('id'))->orderBy(\DB::raw('rand()'))->distinct()->take(6 - sizeof($event_ids))->get()->lists('event_id')->toArray());
             if (sizeof($event_ids) < 6) {
                 $placeCountryWanted = Place::select('id')->whereIn('country', $user->placesWanted->lists('country'))->get();
                 $event_ids = array_merge($event_ids, EventPlace::select('event_id')->whereNotIn('event_id', $user->events->lists('id'))->whereIn('place_id', $placeCountryWanted->lists('id'))->orderBy(\DB::raw('rand()'))->distinct()->take(6 - sizeof($event_ids))->get()->lists('event_id')->toArray());
             }
         }
     }
     $events = Event::where('date_start', '>=', new \DateTime('today'))->whereIn('id', $event_ids)->get();
     if (sizeof($event_ids) < 6) {
         $events = $events->merge(Event::where('date_start', '>=', new \DateTime('today'))->orderBy(\DB::raw('rand()'))->take(6 - sizeof($event_ids))->get());
     }
     $auth_name = \Auth::User()->first_name;
     //$events = Event::take(5)->get();
     return view('home', compact('auth_name', 'events'));
 }
Example #17
0
 public function store()
 {
     // TODO:  Add From < To date validation
     // TODO:  Should only be able to save in certain circumstances?
     $Input = Request::all();
     $objVacation = $Input['VacationID'] ? \App\VacationRequest::findOrFail($Input['VacationID']) : new \App\VacationRequest();
     $VacationID = $Input['VacationID'] ?: 'new';
     $Validator = Validator::make($Input, ['From' => 'required|date', 'To' => 'required|date']);
     if ($Validator->fails()) {
         return redirect('/admin/vacations/edit/' . $VacationID)->withErrors($Validator);
     }
     $objUser = \Auth::User();
     $objVacation->from = date('Y-m-d H:i:s', strtotime($Input['From']));
     $objVacation->to = date('Y-m-d H:i:s', strtotime($Input['To']));
     $objVacation->comments = $Input['Comments'];
     // Set once from person creating it, and that is the only time it can be edited.
     if (!$objVacation->id) {
         $objVacation->user_id = $objUser->id;
     }
     if (Request::get('Type') == VacationRequest::TYPE_HOLIDAY) {
         $objVacation->status = \App\VacationRequest::STATUS_APPROVED;
     } else {
         // Only admins can change status and status always starts pending.
         if ($objUser->role == \App\User::ROLE_ADMIN && $VacationID != 'new') {
             if ($Input['Status'] != \App\VacationRequest::STATUS_PENDING) {
                 $objVacation->approved_by = $objUser->id;
             }
             $objVacation->status = $Input['Status'] ?: \App\VacationRequest::STATUS_PENDING;
         }
     }
     $objVacation->type = $Input['Type'];
     $objVacation->save();
     if ($Input['Type'] == \App\VacationRequest::TYPE_HOLIDAY) {
         $Path = Request::get('ReturnTo') == 'Dashboard' ? '' : '/vacations/holidays';
     } else {
         $Path = Request::get('ReturnTo') == 'Dashboard' ? '' : '/vacations';
     }
     return redirect("/admin{$Path}")->with('FormResponse', ['ResponseType' => static::MESSAGE_SUCCESS, 'Content' => Request::get('Type') . ' saved successfully']);
 }
Example #18
0
 public function __construct()
 {
     $this->objLoggedInUser = \Auth::User();
     if (!$this->objLoggedInUser || !$this->objLoggedInUser->HasPermission('Admin/View')) {
         Abort('404');
     }
     View::share('objLoggedInUser', $this->objLoggedInUser);
     View::share('ActiveClass', static::ACTIVE_CLASS);
     $FormResponse = Session::get('FormResponse') ? Session::get('FormResponse') : [];
     View::share('FormResponse', $FormResponse);
     $NewOrderCount = \App\Invoice::perminvoices($this->objLoggedInUser)->new()->count();
     $AssignedOrderCount = \App\Invoice::perminvoices($this->objLoggedInUser)->assigned($this->objLoggedInUser)->count();
     $FinalizedOrderCount = \App\Invoice::perminvoices($this->objLoggedInUser)->finalized()->count();
     $TotalOrderCount = \App\Invoice::perminvoices($this->objLoggedInUser)->count();
     $ContactUsCount = \App\Invoice::perminvoices($this->objLoggedInUser)->contact()->new()->count();
     $ReviewedCount = \App\Invoice::perminvoices($this->objLoggedInUser)->reviewed()->count();
     View::share('ReviewedCount', $ReviewedCount);
     View::share('ContactUsCount', $ContactUsCount);
     View::share('NewOrderCount', $NewOrderCount);
     View::share('AssignedOrderCount', $AssignedOrderCount);
     View::share('FinalizedOrderCount', $FinalizedOrderCount);
     View::share('TotalOrderCount', $TotalOrderCount);
     // No parent constructor.  All is well.
 }
 public function borrar(Request $request)
 {
     if ($request->ajax()) {
         $user = \Auth::User();
         if ($user->isAdmin) {
             $simcards = \DB::select("delete from recargas");
             return 1;
         }
     }
 }
 public function index()
 {
     $user = \Auth::User();
     $subjects = $user->subjects()->get();
     return view('user.index')->with(['user' => $user, 'subjects' => $subjects]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = \Request::all();
     $passenger = new Passenger();
     $passenger->title = $input['passenger_title'];
     $passenger->name = $input['passenger_name'];
     $passenger->sex = $input['passenger_sex'];
     $passenger->age = $input['passenger_age'];
     $passenger->address_line_1 = $input['passenger_address1'];
     $passenger->address_line_2 = $input['passenger_address2'];
     $passenger->address_line_3 = $input['passenger_address3'];
     $passenger->state = $input['passenger_state'];
     $passenger->country = $input['passenger_country'];
     $passenger->occupation = $input['passenger_occupation'];
     $passenger->cabin_id = $input['cabin_form'];
     $passenger->save();
     $reservation = new Reservation();
     $reservation->cruise_id = $input['cruise_form'];
     $reservation->cabin_id = $input['cabin_form'];
     $reservation->customer_id = \Auth::User()->id;
     $reservation->save();
     $cabin = Cabin::where('id', $input['cabin_form'])->first();
     $cabin->occupied = false;
     $cabin->save();
     return view('pages.index')->with('title', 'Welcome');
 }
Example #22
0
 public function __construct()
 {
     $this->middleware('auth');
     $this->currentUser = \Auth::User();
 }
 public function borrar(Request $request)
 {
     if ($request->ajax()) {
         $user = \Auth::User();
         if ($user->isAdmin) {
             \DB::select("delete from comisiones");
             return 1;
         }
     }
 }
Example #24
0
 public function ProcessSaleRequest($Input)
 {
     // Get logged user, or register as guest
     $objUser = \Auth::User() ?: \App\User::GetGuestAccount();
     // TODO:  Nice error handling would be nice
     if (!$objUser) {
         App::abort('500', 'Invalid form request:  Could not determine user account to submit form');
     }
     // Create invoice
     $objInvoice = new \App\Invoice();
     $objInvoice->user_id = $objUser->id;
     $objInvoice->type = $Input['RequestType'];
     $objInvoice->company_name = $Input['CompanyName'];
     $objInvoice->first_name = $Input['FirstName'];
     $objInvoice->last_name = $Input['LastName'];
     $objInvoice->email = $Input['EmailAddress'];
     $objInvoice->phone = $Input['PhoneNumber'];
     $objInvoice->status = \App\Invoice::STATUS_NEW;
     $objInvoice->comments = $Input['Comments'];
     if (!$objInvoice->save()) {
         App::abort('500', 'Master invoice could not save.  Breaking page.  Not saving invoice items.');
     }
     // Invoice Items
     $tInvoiceItemFields = ['Brand', 'Environment', 'MotivePower', 'Capacity', 'Attachment', 'OperatingHours', 'Accessories' => ['LP Tank', 'Opportunity Charger', 'Seat Belt', 'Strobe Light', 'Fire Extinguisher', 'Side Shifter']];
     if ($Input['RequestType'] == static::REQUEST_TYPE_RENTAL) {
         unset($tInvoiceItemFields[0]);
     }
     // Brand
     foreach ($tInvoiceItemFields as $Item) {
         if (is_array($Item)) {
             foreach ($Item as $Accessory) {
                 if (in_array($Accessory, $Input['Accessories'])) {
                     $objInvoiceItem = new \App\InvoiceItem();
                     $objInvoiceItem->invoice_id = $objInvoice->id;
                     $objInvoiceItem->type = 'Accessory';
                     $objInvoiceItem->title = "{$Accessory}";
                     $objInvoiceItem->status = \App\InvoiceItem::STATUS_ACTIVE;
                     $objInvoiceItem->save();
                 }
             }
         } else {
             if ($Input[$Item]) {
                 $objInvoiceItem = new \App\InvoiceItem();
                 $objInvoiceItem->invoice_id = $objInvoice->id;
                 $objInvoiceItem->type = $Item;
                 $objInvoiceItem->title = $Input[$Item];
                 $objInvoiceItem->status = \App\InvoiceItem::STATUS_ACTIVE;
                 $objInvoiceItem->save();
             }
         }
     }
     EmailController::sendSalesEmail($Input);
     return redirect('/forms/success');
 }
Example #25
0
 public function index()
 {
     $user = \Auth::User();
     $employees = $user->employees()->get();
     return view('user.index')->with(['user' => $user, 'employees' => $employees]);
 }
Example #26
0
 public function increasePoints(Request $request)
 {
     $user = UserGame::user_game($request->gameid, \Auth::User()->id);
     $points = $user[0]->points + $request->points;
     UserGame::updatePoints($request->gameid, \Auth::User()->id, $points);
 }
Example #27
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(AlmacenesRequest $request)
 {
     $almacenes = new Almacenes($request->all());
     \Auth::User()->almacenes()->save($almacenes);
     return redirect()->route('almacenes.show', $almacenes->id);
 }
Example #28
0
 public function control_vendedores()
 {
     $user = \Auth::User();
     if (!$user->isContabilidad) {
         $nombres = \DB::select("select distinct(nombre) from asesores inner join control_vendedores on asesores.cedula = control_vendedores.cedula");
         return view('/controlVendedoresAdmin', array('user' => $user, 'nombres' => $nombres));
     }
 }
Example #29
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(PotrerosRequest $request)
 {
     $potreros = new Potreros($request->all());
     \Auth::User()->potreros()->save($potreros);
     return redirect()->route('potreros.show', $potreros->id);
 }
 public function descargar(Request $request)
 {
     if ($request->ajax()) {
         $user = \Auth::User();
         $distribuidor = $request['distribuidor'];
         if ($distribuidor == null) {
             $distribuidor = $user->name;
         }
         $registros = \DB::select("select * from carteras inner join users on carteras.email = users.email where users.name = ? order by fecha asc", [$distribuidor]);
         $total = 0;
         $myfile = fopen("temp/cartera.csv", "w");
         fwrite($myfile, $distribuidor . "\n");
         fwrite($myfile, "FECHA,DESCRIPCION,CANTIDAD,V. UNITARIO,TOTAL\n");
         foreach ($registros as $registro) {
             $total += $registro->valor_unitario * $registro->cantidad;
             fwrite($myfile, $registro->fecha . ";" . $registro->descripcion . ";" . $registro->cantidad . ";" . $registro->valor_unitario . ";" . $registro->valor_unitario * $registro->cantidad . "\n");
         }
         fwrite($myfile, ", TOTAL GENERAL," + $total + " \n");
         fclose($myfile);
         return 1;
     }
 }