|
7 | 7 | use Illuminate\Http\Request;
|
8 | 8 | use Storage;
|
9 | 9 | use App\pro_cat;
|
| 10 | +use Image; |
10 | 11 |
|
11 | 12 | class AdminController extends Controller {
|
12 | 13 |
|
@@ -137,17 +138,29 @@ public function editProImage(Request $request) {
|
137 | 138 | $proid = $request->id;
|
138 | 139 |
|
139 | 140 | $file = $request->file('new_image');
|
140 |
| - $filename = $file->getClientOriginalName(); |
141 | 141 |
|
142 |
| - $path = 'upload/images'; |
143 |
| - $file->move($path, $filename); |
| 142 | + $filename = time() . '.' . $file->getClientOriginalName(); |
144 | 143 |
|
| 144 | + $S_path = 'upload/images/small'; |
| 145 | + $M_path = 'upload/images/medium'; |
| 146 | + $L_path = 'upload/images/large'; |
145 | 147 |
|
146 |
| - DB::table('products')->where('id', $proid)->update(['pro_img' => $filename]); |
| 148 | + $img = Image::make($file->getRealPath()); |
| 149 | + //$img->crop(300, 150, 25, 25); |
| 150 | + $img->resize(100, 100)->save($S_path . '/' . $filename); |
| 151 | + $img->resize(500, 500)->save($M_path . '/' . $filename); |
| 152 | + $img->resize(1000, 1000)->save($L_path . '/' . $filename); |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | + // $file->move($path, $filename); |
147 | 157 |
|
| 158 | + |
| 159 | + DB::table('products')->where('id', $proid)->update(['pro_img' => $filename]); |
| 160 | + return redirect('/admin/products'); |
148 | 161 | //echo 'done';
|
149 |
| - $Products = DB::table('products')->get(); // now we are fetching all products |
150 |
| - return view('admin.products', compact('Products')); |
| 162 | + // $Products = DB::table('products')->get(); // now we are fetching all products |
| 163 | + // return view('admin.products', compact('Products')); |
151 | 164 | }
|
152 | 165 |
|
153 | 166 | //for delete cat
|
|
0 commit comments