Intervention / Image Upload Error {{ Image source not readable }} - php

I am trying to add a profile image upload in Laravel 5.1. I used the Intervention/Image Package but when I try to upload the image I get this error:
NotReadableException in AbstractDecoder.php line 302: Image source not readable
This is my PhotoController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Image;
use Input;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class PhotoController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index() {}
/**
* 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)
{
$img = Image::make($request->file('photo'));
$img->save('image.png');
}
/**
* 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) {}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id) {}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id) {}
}
This is my html form:
<header>
<div class="student_profile_sub_header w100">
<div class="container ccenter">
<div class="student_profile_name">
<h4>{{$student->name}} {{$student->surname}}</h4>
</div>
<div class="student_profile_image">
<img src="{{asset('assets/profile_image.png')}}">
</div>
<form method="POST" action="../student/profile/imageupload">
{!! csrf_field() !!}
<input type="file" name="photo">
<input type="submit" value="Upload Image" name="submit">
#foreach($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</form>
</div>
</div>
</header>

Add the following parameter in your form tag:
enctype="multipart/form-data"
And change for this in make:
$img = Image::make($request->file('photo')->getRealPath());

This is not to answer the OP's question, but to answer someone else's who is here with the same question with a different context.
If you are using File System method like storeAs() then you are actually uploading your file under /storage/app/public/ from /public/ scope. If so, you will need to run the following command:
php artisan storage:link
This command will create a shortcut link to the /storage directory under /public directory, and things should work normal.

Try using laravel collective, Make sure you have checked files to true if you are using laravel collective
{{ Form::open(['route'=>'your-route', 'class'=>'form',**'files'=>true**]) }}
{{ Form::close()}}`
, then when requesting your file in store function add the getRealPath() like this Image::make(Input::file('artist_pic')->getRealPath())->resize(120,75);

It was $img=Image::make('photo')->resize(300, 200);
I changed it to $img=Image::make($request->file('photo'))->resize(300, 200);
And work for me.

$filenamewithextension = $picture->getClientOriginalName();
$filename = pathinfo($filenamewithextension, PATHINFO_FILENAME);
$extension = $picture->getClientOriginalExtension();
$thumbnail = $filename . '_thumbnail_' . time() . '.' . $extension;
$original_picture = $filename . '_original_' . time() . '.' . $extension;
$picture->storeAs('public/profile_images', $original_picture);
$picture->storeAs('public/profile_images/thumbnail', $thumbnail);
$thumbnailpath = public_path('storage/profile_images/thumbnail/' . $thumbnail);
$this->createThumbnail($thumbnailpath, 150, 93);
$picture_path = public_path('storage/profile_images/' . $original_picture);
$this->createThumbnail($picture_path, 550, 340);
$profile_pic = new Profile_Picture();
$profile_pic->user_id = Auth::user()->id;
$profile_pic->picture_path = $original_picture;
$profile_pic->thumbnail = $thumbnail;
$profile_pic->default = 0;
$profile_pic->isVerified = 1;
$profile_pic->save();
Also check that your corresponding paths are correct , that is the image path where you are storing the image and where you are fetching the image from are simmilar

in my case, the image does not exist in its path, while putting the laravel intervention code.
Make sure your image exists in that path.

Related

Laravel File Uploading | Fetching Files from MySQL Database to view in laravel

I do not now how to show my files from laravel. the database contains path for the files and now I need to fetch my files and display them in laravel.
files.blade.php
#extends('dashboard.layouts.dashboard-layout')
#push('css')
#endpush
#section('content')
<div class="d-flex vw-100 vh-100 justify-content-center align-items-center">
<img src="storage/{{$savedfile->filename}}" alt="">
</div>
<div class="d-flex vw-100 vh-100 justify-content-center align-items-center">
<form method="POST" enctype="multipart/form-data" action="{{route('dashboard.files')}}">
#csrf
<div class="form-group">
<label for="exampleFormControlFile1">Example file input</label>
<input type="file" class="form-control-file" name="uploadedfile" id="exampleFormControlFile1">
</div>
<div class="form-group"><button class="btn btn-success">Upload the file</button></div>
</form>
</div>
#endsection
#push('script')
#endpush
The <img src="storage/{{$savedfile->filename}}" alt="" /> is the file needs to be shown
Fileupload Controller
<?php
namespace App\Http\Controllers;
use App\Models\Fileupload;
use Illuminate\Http\Request;
class FileuploadController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* 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 files(Request $request)
{
$file = $request->file('uploadedfile');
$filename = $file->getClientOriginalName();
$filename = time(). '.' .$filename;
$path = $file->storeAs('public/docs', $filename);
Fileupload::create(['filename' => $path]);
return view('dashboard.files')->with('savedfile', $savedfile);
}
/**
* Display the specified resource.
*
* #param \App\Models\Fileupload $fileupload
* #return \Illuminate\Http\Response
*/
public function show(Fileupload $fileupload)
{
//
}
/**
* Show the form for editing the specified resource.
*
* #param \App\Models\Fileupload $fileupload
* #return \Illuminate\Http\Response
*/
public function edit(Fileupload $fileupload)
{
//
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param \App\Models\Fileupload $fileupload
* #return \Illuminate\Http\Response
*/
public function update(Request $request, Fileupload $fileupload)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param \App\Models\Fileupload $fileupload
* #return \Illuminate\Http\Response
*/
public function destroy(Fileupload $fileupload)
{
//
}
}
This is the controller for posting and returning the files.
The return view('dashboard.files')->with('savedfile', $savedfile) is the code to return and view my files.
However...
This is the error I'm getting
Error Image
I do not know why but its stressing already
The error is clear.$savedFile is undefined .so you have change it like below
public function files(Request $request)
{
$file = $request->file('uploadedfile');
$filename = $file->getClientOriginalName();
$filename = time(). '.' .$filename;
$file->storeAs('public/docs', $filename);
Fileupload::create(['filename' => $path]);
$path ="docs/".$filename;
return view('dashboard.files')->with('savedfile', $path);
}
or
public function files(Request $request)
{
$file = $request->file('uploadedfile');
$filename = $file->getClientOriginalName();
$filename = time(). '.' .$filename;
$file->storeAs('public/docs', $filename);
Fileupload::create(['filename' => $path]);
$path = \Illuminate\Support\Facades\Storage::url("docs/".$filename)
return view('dashboard.files')->with('savedfile', $path);
}
so in your view
<img src="{{asset($savedfile)}}" />
Updated
Also better way is to create separate file system for doc like below
In config/filesystem.php
'docs' => [
'driver' => 'local',
'root' => storage_path('app/public/docs'),
'url' => env('APP_URL').'/storage/docs',
'visibility' => 'public',
],
and in your controller
$path=Storage::disk('docs')->url($filename);
so in your blade file
<img src="{{$savedfile}}" />

how to get information from another controller in laravel

I would like to save information using another controller to store it in the database.
in my situation, there are two controllers:
PostingsController
CommentsController
I could make the create function for comment using CommentsController, but I could not save post_id in the database from CommentsController.
I would like to save post_id using PostingsController because it has:
//if user did not fill the form properly
//error messages will popup
$this->validate($request, [
'comment' => 'required',
]);
//if user filled the form properly
//store the form
$comment = new Comment();
//for connecting both user and comment
$comment->user_id = Auth::id();
//to store comment
$comment->post_id = //I want to save post_id from PostingsController
//to store comment
$comment->comment = $request->input('comment');
//save all user input
$comment->save();
dd($comment);
I have set $comment = Posting::id();, but it could not work. the error is:
BadMethodCallException
Call to undefined method App\Models\Posting::id()
my PostingsController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Posting;
use App\User;
use Illuminate\Support\Facades\Auth;
class PostingsController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
//this is how to get all posting, but this shows only all posting
// $postings = Posting::all();
// $postings->load('user');
//this is how to get all posting with created_at and descending order.
$postings = Posting::orderBy('created_at', 'desc')->get();
//should be function name
$postings->load('user');
return view('index')->with('postings', $postings);
}
/**
* Show the form for creating a new resource.
*
* #return \Illuminate\Http\Response
*/
public function create()
{
return view('create');
}
/**
* Store a newly created resource in storage.
*
* #param \Illuminate\Http\Request $request
* #return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//if user did not fill the form properly
//error messages will popup
$this->validate($request, [
'posting' => 'required',
]);
//if user filled the form properly
//store the form
$posting = new Posting();
//for connecting both user and posting
$posting->user_id = Auth::id();
//to store posting
$posting->post = $request->input('posting');
//save all user input
$posting->save();
return redirect()->to('/home')->with('success', 'Posting created successfully!');
}
/**
* Display the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function show($id)
{
$posting = Posting::find($id);
return view('show')->with('posting', $posting);
}
/**
* Show the form for editing the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function edit($id)
{
//this is the way how to find posting of authenticated user
$posting = Posting::find($id);
return view('edit')->with('posting', $posting);
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//if user did not fill the form properly
//error messages will popup
$this->validate($request, [
'posting' => 'required',
]);
//if user filled the form properly
//store the form
$posting = Posting::find($id);
//to store posting
$posting->post = $request->input('posting');
//save all user input
$posting->save();
return redirect()->to('/home')->with('success', 'Posting edited successfully!');
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
$posting = Posting::find($id);
$posting->delete();
return redirect()->to('/home')->with('success', 'Posting deleted successfully');
}
}
my CommentsController:
<?php
namespace App\Http\Controllers;
use App\Models\Posting;
use App\Models\Comment;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class CommentsController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* #return \Illuminate\Http\Response
*/
public function create()
{
return view('comments.create');
}
/**
* Store a newly created resource in storage.
*
* #param \Illuminate\Http\Request $request
* #return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//if user did not fill the form properly
//error messages will popup
$this->validate($request, [
'comment' => 'required',
]);
//if user filled the form properly
//store the form
$comment = new Comment();
//for connecting both user and comment
$comment->user_id = Auth::id();
//to store comment
$comment->post_id = //problem
//to store comment
$comment->comment = $request->input('comment');
//save all user input
$comment->save();
dd($comment);
}
/**
* 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)
{
//
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
create.comments in view:
#extends('layouts.app')
#section('content')
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">
<div class="float-left m-2">Create new comment</div>
<span class=" ">Go back</span>
</div>
<div class="card-body">
#if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
#endif
<form method="post" action="/comments" >
#csrf
<input type="hidden" name="post_id" id="post_id" value="{{ $post->id }}" />
<div class="form-group">
<input type="text" class="form-control" name="comment" id="comment" placeholder="Comment what you think!">
</div>
<button type="submit" class="btn btn-primary float-right">Comment</button>
</form>
</div>
</div>
</div>
</div>
#endsection
Following the principle of Separation of Concerns you can move the logic into another module such as services.
I would suggest adding a new folder app/services and adding a service-class for each logic that needs to be implemented, eg. app/services/AddCommentToPostService.php.
This will also make testing of the system easier.
you can use app method to call controller method of another controller in laravel app('App\Http\Controllers\ControllerName')->functionName();

Method App\Http\Controllers\Elibrary::save does not exist

I try to make library of pdf files. which i want to store pdf title-name and file name also upload this pdf in project storage. but server show me this error.I can't understand what can I do.
Method App\Http\Controllers\Elibrary::save does not exist.
my error message
this is my elibrary controller file which i chech filename and store file name in database also stored in public/images location
I find this code on this linkuload file tutorial
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Elibrary;
class ElibraryController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index(Request $request){
$elibrary = Elibrary::orderBy('id','DESC')->paginate(5);
return view('e-library',compact('elibrary'))
->with('i', ($request->input('page', 1) - 1) * 5);
}
/**
* 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)
{
$this->validate($request, [
'title' => 'required',
'efile' => 'required|max:4000',
]);
if($file= $request->file('file')){
$name = $file->getClientOriginalName();
if($file->move('images', $name)){
$elibrary = new Post;
$elibrary->efile = $name;
$elibrary->save();
return redirect()->route('e-library');
};
}
$elibrary = new Elibrary([
'title' => $request->get('title'),
'efile' => $request->file('file'),
]);
$elibrary->save();
return redirect()->route('e-library');
}
/**
* 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)
{
//
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
This is my route file code
Route::post('/store', 'Elibrary#store')->name('store');
this is e-library.blade.php file from
<form action="/store" method="post" enctype="multipart/form-data">
#csrf()
<div class="form-group">
<input type="text" class="form-control"name="title" placeholder="Name">
</div>
<div class="form-group">
<input type="file" class="form-control"name="efile" >
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary btn-send-message" >
</div>
</form>
this is my model file of Elibrary.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Elibrary extends Model
{
public $fillable = ['title','efile'];
}
this is my migration file
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateElibrariesTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('elibraries', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->string('efile');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::dropIfExists('elibraries');
}
}
How i can show this pdf with the help show function in show.blade.php
You're creating new instances of Elibrary in your controller methods. Elibrary is a controller class but it looks like you're treating it as a model.
Maybe try changing all of your new Elibrary() to new Post since it looks like that might be what you're trying to accomplish.
If thats the case, you will also need to make efile fillable in your Post model.
$elibrary = Post::orderBy('id','DESC')->paginate(5);

Why $post is not an object in the third code?

I started learning Laravel today and I've ran into a problem.
There are 3 seperated posts. Each one has titles and I made an other title too which should be in the url of the page of the posts, for example:
something.com/posts/post_three instead of posts/3
With the id version (posts/3) it worked perfectly, but I tried to change the code so it will go to posts/post_three, but I keep getting the following error:
Trying to get property 'created_at' of non-object (View:
C:\xampp\htdocs\lsapp\resources\views\posts\show.blade.php)
I have the following codes which I've changed something in:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Post;
class PostsController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
$posts = Post::orderBy('urltitle', 'desc')->paginate(5);
return view('posts.index')->with('posts', $posts);
}
/**
* 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($urltitle)
{
$post = Post::find($urltitle);
return view('posts.show')->with('post', $post);
}
/**
* Show the form for editing the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function edit($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)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
-
#extends('pages.layouts.app')
#section('content')
<h1 style="text-align: center">Posts</h1>
#if(count($posts) > 0)
#foreach($posts as $post)
{{$post->urltitle}}
<div class="card" style="padding-top: 8px">
<div class="card-body">
<h3>{{$post->title}}</h3>
<small>Written on: {{$post->created_at}}</small>
</div>
</div>
#endforeach
<div style="justify-content: center; display: flex;">{{$posts->links()}}</div>
#else
<p>No posts found</p>
#endif
#endsection
-
And here is the code which can't "recognise" $post
#extends('pages.layouts.app')
#section('content')
<div class="jumbotron text-center">
Go Back
<h1>{{$post->title}}</h1>
<div>{{$post->body}}</div>
<hr>
<small>Written at {{$post->created_at}}</small>
</div>
#endsection
This is where the error occurs:
public function show($urltitle)
{
$post = Post::find($urltitle); // <----
return view('posts.show')->with('post', $post);
}
The find() method will check for a primmary key (id by default) that hold the given value, so this both sentences are equal:
$post = Post::find($id);
// equals to:
$post = Post::where('id', $id)->first();
but given the fact that you are passing the urltitle instead of the $id, you should use a more generic approach:
$post = Post::where('urltitle', $urltitle)->first();
Also, as #devon said, you should check if a value is returned:
$post = Post::where('urltitle', $urltitle)->first();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
if( ! $post)
{
// do something
}
or throw an error if the query returns nothing:
$post = Post::where('urltitle', $urltitle)->firstOrFail();
^^^^^^^^^^^^^

Missing required parameters for route

I want to ask how to fix this error. I have this error Missing required parameters for [Route: userprofile.edit] [URI: userprofile/{userprofile}/edit]. (View: C:\xampp\htdocs\code\task1\resources\views\userprofile\create.blade.php)
I have user informations in view userprofile\create.blade.php and after submitting the button I want to relocate the page on the userprofile\edit.blade.php
This is my userProfileController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\User;
class userProfileController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* #return \Illuminate\Http\Response
*/
public function create()
{
return view("userprofile.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)
{
$user = User::find($id);
return view('userprofile.edit')->withUser($user);
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
Also the route for this views
Route::group(['namespace' => 'User'], function(){
Route::get('/userprofile/{id}/edit', ['as' => 'userprofile.edit', 'uses' => 'userProfileController#edit']);
});
Route::resource('userprofile','userProfileController');
And my route action in the button in create.blade.php
<input type="submit" class="btn btn-primary" action="{{ route('userprofile.edit') }}" value="Edit profile">
If you have any idea why is this error, please write me!
Thank you.
You can't add action to a input field. Add action to form tag. You are not passing any id in the form action. Add id to your action like I have passed id = 1
<form method="post" action="{{ route('userprofile.edit', ['id' => 1]) }}">
Update
First of all you have to create a user with given data and after that you redirect to the edit page with the generated id.
You need to set a default value for the id passed in to the edit and other methods, like so:
public function edit($id = null)
{
$user = User::find($id);
return view('userprofile.edit')->withUser($user);
}
Here, we are setting the default value of id to null. Next, check in your method if it is null and if so, return with an error or whatever you wanna do in that situation:
public function edit($id = null)
{
if(!$id)
return back()->with(['error'=>'No document selected for editing.']);
$user = User::find($id);
return view('userprofile.edit')->withUser($user);
}
if(!$id)
return back()->with(['error'=>'No document selected for editing.']);
This is your check and if the id is null, we simply return back and notify the user (You must check for the error in your blade view and display it if it exists).
instead of
<input type="submit" class="btn btn-primary" action="{{ route('userprofile.edit') }}" value="Edit profile">
use
<a href="{{url('/userprofile/'.PROFILE ID.'/edit')" class="btn btn-primary" >Edit profile</a>
PROFILE ID must be id

Categories