I am currently doing a project called Doctor Management System.In this project I am stuck because i cannot upload my image & cannot define where my image is situated.I want to show 2 hospital info per page but it gives me all the data.Please help me solving this. My Route file is
Route::get('/profile/{id}', array('as' =>'profile' ,'uses' => 'ProfileController@index'));
//Route::get('/update', array('as' =>'update' ,'uses' => 'ProfileController@postUpdate'));
Route::get('/profile/{profile_id}/edit', [
'uses' => 'ProfileController@getUpdate',
'as' => 'edit'
]);
Route::post('profile/update', [
'uses' => 'ProfileController@postUpdate',
'as' => 'update'
]);
My Blade template is
<?php $active="profile"; ?>
@extends('admin.dashboard')
@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
User Profile
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li class="active">User profile</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<!-- left column -->
<div class="col-md-10">
<!-- general form elements -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Quick Example</h3>
</div>
<!-- /.box-header -->
<!-- form start -->
<form action="" role="form" method="post" enctype="multipart/form-data">
<div class="box-body">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" name="name" id="name" value="">
</div>
<div class="form-group">
<label for="institute">Institute Name</label>
<input type="text" class="form-control" name="institute" id="institute" value="">
</div>
<div class="form-group">
<label for="education">Degree</label>
<input type="text" class="form-control" name="education" id="education" value="">
</div>
<div class="form-group">
<label for="specialty">Specialty</label>
<input type="text" class="form-control" name="specialty" id="specialty" value="">
</div>
<div class="form-group">
<label for="phone">Mobile No.</label>
<input type="number" class="form-control" name="phone" id="phone" value="">
</div>
<div class="form-group">
<label for="time">Visiting Time</label>
<input type="text" class="form-control" name="time" id="time" value="">
</div>
<div class="form-group">
<label for="fee">Fee</label>
<input type="number" class="form-control" name="fee" id="fee" value="">
</div>
<div class="form-group">
<label for="division">Division</label>
<select name="division_id">
@foreach($divisions as $division)
<option value=""></option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="district">District</label>
<select name="district_id">
@foreach($districts as $district)
<option value=""></option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="dcategory">Category</label>
<select name="dcategory_id">
@foreach($dcategories as $dcategory)
<option value=""></option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="image">Chose the picture</label>
<input type="file" class="form-control" name="image" id="image" value="">
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<button type="submit" class="btn btn-primary">Submit</button>
<input type="hidden" name="_token" value="">
<input type="hidden" name="id" value="">
</div>
</form>
</div>
<!-- /.box -->
</div>
<!--/.col (left) -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
@endsection
My controller is
public function getUpdate($id) {
$divisions = Division::all();
$districts = District::all();
$dcategories = Dcategory::all();
$profile = Auth::user();
$doctor=Doctor::find($id);
// $post = Post::find($post_id);
// if(!$post) {
// return redirect()->route('blog.index')->with(['fail' => 'Post Not Found']);
// }
return view('admin.article.edit')
->with('divisions',$divisions)
->with('districts',$districts)
->with('dcategories',$dcategories)
->with('profile',$profile)
->with('doctor',$doctor);
}
public function postUpdate(Request $request ) {
$this->validate($request, [
'name' => 'required|max:120',
'fee' => 'required|max:5',
'division_id' => '',
'district_id' => '',
'dcategory_id' => '',
'education' => '',
'institute' => '',
'specialty' => '',
'hospital' => '',
'time' => '',
'phone' => '',
'image' =>''
]);
$doctor = Doctor::find($request['id']);
$doctor->name = $request['name'];
$doctor->division_id = $request['division_id'];
$doctor->district_id = $request['district_id'];
$doctor->dcategory_id = $request['dcategory_id'];
$doctor->institute = $request['institute'];
$doctor->education = $request['education'];
$doctor->specialty = $request['specialty'];
$doctor->hospital = $request['hospital'];
$doctor->phone = $request['phone'];
$doctor->time = $request['time'];
$doctor->fee = $request['fee'];
$photo = Photo::find($request['id']);
$upload='uploads/logo';
$file=Input::file('file');
$file->move('uploads', $file->getClientOriginalName());
$photo->image = $request['image'];
// $file = Input::file('pic');
// $img = Image::make($request->file('pic')->getRealPath());
// //$img = Image::make($file);
// Response::make($img->encode('jpeg'));
// $doctor->pic = $img;
$doctor->update();
$photo->update();
return redirect()->route('profile')->with(['success' => 'Profile Successfully Updated']);
}
Plz help me how can i upload my image in upload directory in public folder.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire