here my code and i want to save image url in database i am using laravel my question is how i save image url in database
public function save(Request $req) { if(request()->hasFile('photo')){
$path = base_path() . '/public/user-uploads/employee-docs/';
$repath = '/public/user-uploads/employee-docs/'.request('project');
if (!file_exists($path))
{
mkdir($path);
}
$path = $path.'/'.request('project');
if (!file_exists($path))
{
mkdir($path);
}
$name = Carbon::now()->format('Y-m-d-H-i-s_u');
$file1 = request()->file('photo');
if($file1->isValid()) {
$file1->move($path, $name.'.'.$file1->getClientOriginalExtension());
$file1_url = $repath.'/'.$name.'.'.$file1->getClientOriginalExtension();
$photo = new attendance;
$photo ->user_id=$req->user_id;
$photo ->image_url=$req->image_url;
return ['status'=>1, 'data'=>$file1_url];
} else{
return ['status'=>0, 'data'=>'Invalid image'];
}
} else{
return ['status'=>0, 'data'=>'There is no image'];
}
}