Bonjour,
j'ai un probléme avec l'affichge d'avatar. Le nom d'image existe dans la BD ainsi dans le dossier dans lequel stocker les images mais l'image apparaitre sous forme lien cassé. Merci de m'aider
profil.blade.php
@extends('layouts.app')
@section('htmlheader_title')
Profile
@endsection
@section('main-content')
<!-- Main row -->
<div class="row">
<!-- Left col -->
<section class="col-lg-7 connectedSortable">
<div class="box box-primary">
<div class="box-header with-border">
<img src="uploads/avatars/{{ $user->avatar }}" style="width: 160px; height: 160px; float: left; border-radius: 50%; margin-left: 25px">
{{ $user->nom }} </br>
{{ $user->prenom}}</br>
{{ $user->email}}</br>
{{ $user->telephone}}</br>
<form enctype="multipart/form-data" action="profile" method="post">
<label>modifier photo de profil</label>
<input type="file" name="avatar">
<input type="hidden" name="_token" value="{{csrf_token()}}">
<input type="submit" class="pull-right btn btn-sm btn-primary">
</form>
</div>
</div>
</section>
<!-- /.Left col -->
<!-- right col (We are only adding the ID to make the widgets sortable)-->
<section class="col-lg-5 connectedSortable">
</section>
<!-- right col -->
</div>
</div>
@endsection ```
UserController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Illuminate\Support\Facades\Auth;
use Image;
class UserController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$user = Auth::user();
return view('admins.profil.profile', compact('user'));
}
public function updateAvatar(Request $request ){
if($request->hasFile('avatar')){
$avatar= $request->file('avatar');
$filename=time().'.'.$avatar->getClientOriginalExtension();
Image::make($avatar)->resize(300,300)->save(public_path('uploads/avatars/'.$filename));
$user = Auth::user();
$user->avatar= $filename;
$user->save();
}
$user = Auth::user();
return view('admins.profil.profile', compact('user'));
}
}
Routes.php
Route::get('/', function () {
return view('welcome');
});
//Route::auth();
//Route::get('/home', 'HomeController@index');
//Route::group(['prefix' => 'admin', 'middleware' => ['role:administrateur']], function () {
// Route::get('/home', 'HomeController@index');
// Route::resource('actualities', 'ActualitiesController');
//});
Route::group(['prefix' => 'admin'], function(){
Route::get('/home', 'HomeController@index');
Route::get('/actualities', 'ActualitiesController@index')->name('actualities');
Route::get('/actualities/create', 'ActualitiesController@create')->name('create-actualities');
Route::post('/actualities', 'ActualitiesController@store')->name('store-actualities');
Route::get('/actualities/{id}/edit', 'ActualitiesController@edit')->name('edit-actualities');
Route::post('/actualities/{id}', 'ActualitiesController@update')->name('update-actualities');
Route::get('/actualities/{id}/delete', 'ActualitiesController@destroy')->name('delete-actualities');
Route::get('/actualities/{id}', 'ActualitiesController@show')->name('show-actualities');
Route::get('/profile', 'UserController@index')->name('show-profile');
Route::post('/profile', 'UserController@updateAvatar')->name('update-avatar');
Route::get('/home', 'HomeController@index');
Route::get('/formations', 'FormationsController@index')->name('formations');
Route::get('/formations/create', 'FormationsController@create')->name('create-formations');
Route::post('/formations', 'FormationsController@store')->name('store-formations');
Route::get('/formations{id}/edit', 'FormationsController@edit')->name('edit-formations');
Route::post('/formations/{id}', 'FormationsController@update')->name('update-formations');
Route::get('/formations/{id}/delete', 'FormationsController@destroy')->name('delete-formations');
Route::get('/formations/{id}', 'FormationsController@show')->name('show-formations');
});
Essaye :
{{ asset('uploads/avatars/'.$user->avatar) }}
au lieu de
uploads/avatars/{{ $user->avatar }}
Oui . S'il vous plait Alex pouvez -vous m'aider. Je veux savoir comment envoyer un email et la génération des notifications en laravel 5.2
Notification , si un nouveau utilisateur inscrit une notification sera envoyer à l'administrateur
Bah tu peux faire une table genres admin_notifications avec une colonne "id", une "vue" (booléen) et une "message" (string) t'affiche tous les messages dans la vue admin ou vue=false et une fois qu'ils sont affichés tu mets vue=true