Exemple #1
0
 public function local(Request $request)
 {
     $header = app('request')->header();
     $email = $header['php-auth-user'][0];
     $password = $header['php-auth-pw'][0];
     $check = Auth::attempt(['email' => $email, 'password' => $password]);
     if (!$check) {
         return response('Unauthorized', 401);
     } else {
         $user = Auth::user();
         if ($user->hasRole('admin')) {
             $name = $request->input('name');
             $place = $request->input('place');
             $latitude = $request->input('latitude');
             $longitude = $request->input('longitude');
             $local = new Local();
             $local->name = $name;
             $local->place = $place;
             $local->latitude = $latitude;
             $local->longitude = $longitude;
             $local->save();
             $local->constant = (int) $local->id * 500;
             $local->save();
             return "true";
         } else {
             return response('Unauthorized', 401);
         }
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($id)
 {
     $l = \App\Local::find($id);
     if ($l) {
         return ['mensagens' => $l->mensagens->toArray()];
     }
 }
 public static function boot()
 {
     parent::creating(function ($m) {
         $m->id = sha1(str_random(128));
     });
     parent::created(function ($m) {
         preg_match_all("/(^|[^a-zA-Z0-9])@([a-zA-Z0-9_])+/i", $m->conteudo, $matches);
         $locais = array();
         if (!empty($matches[0])) {
             foreach ($matches[0] as $match) {
                 array_push($locais, preg_replace('/[^a-zA-Z0-9_]/i', "", $match));
             }
         }
         preg_match_all("/(^|[^a-zA-Z0-9])#([a-zA-Z0-9_])+/i", $m->conteudo, $matches);
         $tags = array();
         if (!empty($matches[0])) {
             foreach ($matches[0] as $match) {
                 array_push($tags, preg_replace('/[^a-zA-Z0-9_]/i', "", $match));
             }
         }
         foreach ($tags as $tag) {
             $t = \App\Tag::firstOrCreate(['tag' => $tag]);
             $m->tags()->save($t);
         }
         foreach ($locais as $local) {
             $l = \App\Local::firstOrCreate(['local' => $local]);
             $m->locais()->save($l);
         }
     });
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $data['student'] = Student::find($id);
     $data['title'] = 'Edit ' . $data['student']->fname;
     $data['students_menu'] = 1;
     $data['gender'] = Gender::lists('gender', 'id')->prepend('Please Select');
     $data['bloodGroups'] = BloodGroup::lists('blood_group', 'id')->prepend('Please Select');
     $data['locals'] = Local::lists('local_name', 'id')->prepend('Please Select');
     $data['states'] = State::lists('name', 'id')->prepend('Please Select');
     $data['countries'] = Country::lists('name', 'id')->prepend('Please Select');
     $data['parents'] = StudentParent::select(\DB::raw('concat (fname," ",lname) as full_name, id'))->lists('full_name', 'id')->prepend('Please Select');
     $data['classes'] = StudentClass::lists('name', 'id')->prepend('Please Select');
     $data['religions'] = Religion::lists('religion', 'id')->prepend('Please Select');
     return view('admin.students.edit', $data);
 }
 /**
  * Active the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function active($id)
 {
     $almacen = Local::find($id);
     $almacen->estatus = 'activo';
     $almacen->save();
     $auditoria = new Auditoria();
     $auditoria->content = 'Ha activado un almacen ID: ' . $almacen->id . ' - Nombre: ' . $almacen->nombre;
     $auditoria->user_id = \Auth::user()->id;
     $auditoria->save();
     Flash::success('Almacen activado exitosamente');
     return redirect()->route('admin.almacenes.index');
 }
Exemple #6
0
 public function local()
 {
     $locals = Local::All();
     return $locals;
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $user = User::find($id);
     $talleres = Local::orderBy('nombre', 'DESC')->where('type', 'taller')->lists('nombre', 'id');
     $my_taller = $user->locales->lists('id')->ToArray();
     $almacenes = Local::orderBy('nombre', 'DESC')->where('type', 'almacen')->lists('nombre', 'id');
     $my_almacen = $user->locales->lists('id')->ToArray();
     return view('admin.users.edit', ['user' => $user, 'talleres' => $talleres, 'almacenes' => $almacenes, 'my_taller' => $my_taller, 'my_almacen' => $my_almacen]);
 }
Exemple #8
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use App\Local;
Route::get('/', function () {
    return view('welcome');
});
Route::get('/locais/gerar', function () {
    for ($i = 0; $i < 100; $i++) {
        Local::create(['id' => 0, 'codigo_local' => rand(1, 999999), 'pais' => str_random(10), 'estado' => str_random(10), 'cidade' => str_random(10)]);
    }
});
Route::get('/locais/listar', function () {
    $locais = Local::all();
    foreach ($locais as $local) {
        echo $local->codigo_local . '-' . $local->pais;
        echo '<br/>';
    }
});
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $data['title'] = 'Edit Staff';
     $data['staff'] = Staff::find($id);
     $data['staff_menu'] = 1;
     $data['gender'] = Gender::lists('gender', 'id')->prepend('Please Select');
     $data['countries'] = Country::lists('name', 'id')->prepend('Please Select');
     $data['states'] = State::lists('name', 'id')->prepend('Please Select');
     $data['locals'] = Local::lists('local_name', 'id')->prepend('Please Select');
     $data['staff_types'] = StaffType::lists('staff_type', 'id')->prepend('Please Select');
     return view('admin.staff.edit', $data);
 }
Exemple #10
0
 public function deleteData(Request $request)
 {
     $parameter = $request->input('parameter');
     $local = $request->input('local');
     $data = json_decode($request->input('data'));
     $local = Local::where('name', '=', $local)->get();
     switch ($parameter) {
         case 'device':
             $device = Device::find((int) $data->id + (int) $local[0]->constant);
             $device->delete();
             break;
         case 'mapping':
             $mapping = Mapping::find((int) $data->id + (int) $local[0]->constant);
             $mapping->delete();
             break;
         default:
             break;
     }
     return 'true';
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     return \App\Local::find($id);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $data['parent'] = StudentParent::find($id);
     $data['parents_menu'] = 1;
     $data['title'] = 'Edit Parent';
     $data['gender'] = Gender::lists('gender', 'id')->prepend('Please Select');
     $data['bloodGroups'] = BloodGroup::lists('blood_group', 'id')->prepend('Please Select');
     $data['locals'] = Local::lists('local_name', 'id')->prepend('Please Select');
     $data['states'] = State::lists('name', 'id')->prepend('Please Select');
     $data['countries'] = Country::lists('name', 'id')->prepend('Please Select');
     $data['religions'] = Religion::lists('religion', 'id')->prepend('Please Select');
     return view('admin.parents.edit', $data);
 }