Skip to content

Commit

Permalink
editar perfil
Browse files Browse the repository at this point in the history
  • Loading branch information
gibmyx committed Mar 22, 2020
1 parent 4884393 commit af6f9ae
Show file tree
Hide file tree
Showing 17 changed files with 233 additions and 301 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ protected function create(array $data)
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'last' => $data['last'],
'sex' => $data['sex']
'sex' => $data['sex'],
'profile' =>$data['sex'] == 'mujer' ? 'perfil-mujer-default.jpg' : 'perfil-hombre-default.jpg' ,
]);
}
}
100 changes: 31 additions & 69 deletions app/Http/Controllers/dashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Http\Controllers;

use App\modulos\dashboard\servicios\guardarUsuario;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

Expand All @@ -12,80 +14,40 @@ class dashboardController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function index()
public function dashboard($id)
{
if(Auth::check()){
return view('dashboard');
}else{
return redirect('/');
}
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
return view('dashboard', compact('id'));
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
public function ajax_get_usuario($id)
{
//
$datos = User::where('id', $id)->get()->map(function (User $user){
return [
'id' => $user->id,
'nombre' => $user->name,
'foto' => $user->profile,
'descripcion' => !empty($user->descripcion) ? $user->descripcion : '',
'email' => $user->email,
'proyectos' => $user->proyectos()->count(),
'tareas' => 0,
'seguidores' => 0
];
})->toArray();
$response = [
'perfil' => $datos[0]
];
return response()->json($response, 200);
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
public function ajax_guardar_perfil(Request $request){
$params = $request->input();
try {
(new guardarUsuario())->save($params);
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
$response = [
'message' => "Se a creado el proyecto con exito"
];
}


}
12 changes: 11 additions & 1 deletion app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace App;

use App\modulos\proyectos\models\Proyecto;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Builder;

class User extends Authenticatable
{
Expand All @@ -16,7 +18,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'sex', 'last'
'name', 'email', 'password', 'sex', 'descripcion', 'especialidad', 'profile'
];

/**
Expand All @@ -36,4 +38,12 @@ class User extends Authenticatable
protected $casts = [
'email_verified_at' => 'datetime',
];

public function proyectos()
{
$scope = $this;
return (new Proyecto())->whereHas('miembros', function (Builder $query) use($scope) {
$query->where('user_id', $scope->id);
})->get();
}
}
32 changes: 32 additions & 0 deletions app/modulos/dashboard/servicios/guardarUsuario.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\modulos\dashboard\servicios;

use App\User;
use App\modulos\servicios\guardar;
use Illuminate\Support\Facades\DB;

class guardarUsuario extends guardar
{
public function __construct()
{

}

public function create($params)
{
DB::transaction(function () use ($params) {
User::create($params);
});
}

public function update($params)
{
DB::transaction(function () use ($params) {
$user = User::find($params['id']);
$user->update($params);
});
}


}
4 changes: 2 additions & 2 deletions database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public function up()
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->string('email')->unique()->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('password')->nullable();
$table->rememberToken();
$table->timestamps();
});
Expand Down
35 changes: 35 additions & 0 deletions database/migrations/2020_03_22_152143_update_tabla_user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class UpdateTablaUser extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->text('descripcion', 555)->after('email')->nullable();
$table->string('especialidad', 55)->after('email')->default('');
$table->dropColumn('last');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('descripcion');
$table->dropColumn('especialidad');
});
}
}
3 changes: 1 addition & 2 deletions resources/js/modulos/correo/components/sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<ul class="nav metismenu" id="side-menu">
<li class="nav-header">
<div class="profile-element profile">
<img v-show="data.profile =='defaultProfile.jpg' && data.sex == 'hombre'" height="60px" width="60px" alt="image" class="rounded-circle" src="img/profile/perfil-hombre-default.jpg"/>
<img v-show="data.profile =='defaultProfile.jpg' && data.sex == 'mujer'" height="60px" width="60px" alt="image" class="rounded-circle" src="img/profile/perfil-mujer-default.jpg"/>
<img height="60px" width="60px" alt="image" class="rounded-circle" :src="'/img/profile/'+data.profile"/>
<a data-toggle="dropdown" class="dropdown-toggle" :href="'/dashboard/'+data.user_id">
<span class="block m-t-xs font-bold">{{data.nombre}} {{data.apellido}}</span>
<span class="text-muted text-xs block">Programador BackEnd</span>
Expand Down
Loading

0 comments on commit af6f9ae

Please sign in to comment.