1 2 3 4 5 6 7 |
public function destroy(product $product) { $product->delete(); return response([ 'message' => 'Product updated' ],200); } |
işe yarar kod blokları
1 2 3 4 5 6 7 |
public function destroy(product $product) { $product->delete(); return response([ 'message' => 'Product updated' ],200); } |
zaten resource ile show metodu geliyor. eğer model tanımlamadıysak controller’a
1 2 3 4 5 6 7 8 |
public function show($id) { $product = product::find($id); if($product) return response($product,200); else return response(['message' => 'Ürün bulunamadı'],404); } |
eğer modelimiz varsa
1 2 3 4 |
public function show(product $product) { return response($product,200); /* örnek kullanım */ } |
instagram api kullanırken resim yüklemediğimi ve karşılında invalid request options hatasını aldığımı gördüm. çözümü için yazdım sağa sola ama bulamadım. en son github’a birinin yazdığını gördüm google’dan. o da silmişti. önbellekten ulaştım arkadaşa sağ olsun yardımcı oldu. çözümü bir önceki versiyonu kurmak nasıl mı ?
1 |
composer require mgp25/instagram-php:4.1.0 |
gördüğünüz gibi sonuna 4.1.0 ekledik mi iş tamam oluyor.
validation kısmı
1 2 3 |
$validatedData = $request->validate([ 'image' => 'image|max:1024|mimes:jpeg,jpg,png', ]); |
1024 kb, resim ve uzantısı orada yazanlardan olanların bize gelmesini istiyoruz.
1 2 3 4 |
if($request->hasFile('image')){ /* resim geldi mi */ $imagename =str_slug($request->title).'.'.$request->image->getClientOriginalExtension(); $request->image->move(public_path('/assets/images/img'),$imagename); } |
taylandda yaşayan amcamın oğlu ismail. cin gibi cocuk bizim ismail. kral adam vallaha bak. kendisini çok severim.