public function contactId($id) { $info = info::where('name', 'contact')->limit(1)->get()[0]; $helps = help::all(); $events = event::all(); $services = service::all(); $checkServiceArray = eventServices::where('event_id', $id)->get(); $checkService; $currEvent = event::find($id); foreach ($checkServiceArray as $check) { $checkService[] = $check->service_id; } if (!empty($currEvent)) { return view('pages.contact', compact('helps', 'events', 'services', 'checkService', 'currEvent', 'info')); } return redirect('/contact'); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); $names = new ArrayIterator(array('names' => 'New Permanent Electric Connection', 'New Temporary/Permanent Electric Connection', 'New Permanent Electric Connection Through Panel', 'Temporary Electric Connection', 'New Meter Testing', 'Existing Meter Testing', 'Replace Meter/Meterboard', 'Approve Meter', 'Relocate Existing Meterboard', 'Relocate Existing Meter to Panel', 'Panel Modification Testing', 'Relocate SDB', 'Relocate MDB', 'Temporary Disconnection', 'Permanent Disconnection', 'Reconnection', 'Replace Cable', 'Cable Details and Price')); $i = 1; foreach ($names as $name) { $cat = 1; if ($i >= 5) { $cat = 2; } elseif ($i >= 12) { $cat = 3; } elseif ($i >= 14) { $cat = 4; } \App\service::create(['name' => $name, 'desc' => $faker->paragraph, 'service_category_id' => $cat, 'icon' => $faker->url, 'link' => $faker->url, 'featured' => rand(0, 1), 'order' => $i, 'status' => true]); $i++; } }
public function removecontent($id, $cid) { service::find($id)->contentFiles()->detach($cid); $service = service::find($id); $contents = service::find($id)->contentFiles()->get(); return View::make('admin.services.edit', compact('service', 'contents')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { foreach (servicePic::where('service_id', $id)->get() as $s) { unlink($s->pic); $s->delete(); } foreach (eventServices::where('service_id', $id)->get() as $s) { $s->delete(); } service::find($id)->delete(); return redirect('/'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { service::destroy($id); return Redirect::route('admin.services.index'); }