/** * Run the database seeds. * * @return void */ public function run() { DB::table('products_providers')->truncate(); \App\Models\Product\Provider::create(['name' => 'Samsung', 'website' => 'www.samsung.com', 'logo' => 'samsung.png', 'slug' => 'samsung']); }
/** * Remove the specified resource from storage. * * @param int $id * * @return \Illuminate\Http\Response */ public function destroy($id) { $provider = Provider::with('products')->find($id); if ($provider && $provider->products->isEmpty()) { if ($provider->delete()) { return response()->json(true); } } return response()->json('informatia nu s-a putut sterge', 500); }