public function run() { DB::table('pet_types')->delete(); PetTypes::create(array('name' => 'cat')); PetTypes::create(array('name' => 'dog')); PetTypes::create(array('name' => 'rabits')); PetTypes::create(array('name' => 'tortoise')); PetTypes::create(array('name' => 'snake')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $pet = PetTypes::find($id); $pet->petServices()->detach(); if ($pet->delete()) { return Response::json('Pet successfully deleted.'); } return false; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $service = Services::find($id); $pets = PetTypes::get(); return View::make('services.edit', compact('service', 'pets')); }
</th> </tfoot> <tbody> @if(count($a_service_offered) > 0) @foreach($a_service_offered as $row) @if($row->pet_type_ids != '') <tr> <td>{{ $row->service_name }}</td> <td> <ul> <?php $a_pet_id = explode(",", $row->pet_type_ids); //echo "<pre>"; print_r($a_pet_id); die; $pet_name = ''; foreach ($a_pet_id as $key => $value) { $pet_name = PetTypes::where('id', '=', $value)->pluck('pet_name'); ?> <li>{{ $pet_name }}</li> <?php } ?> </ul> </td> </tr> @endif @endforeach @else <tr> <td colspan="2">No List</td> </tr> @endif
public function serviceAvailable() { $a_service_available = array(); $service_available = ServiceTypes::leftJoin('allocate_services', 'allocate_services.service_type_id', '=', 'service_types.id')->select('service_types.id as service_id', 'service_types.name as service_name', 'allocate_services.*')->orderBy('service_name', 'ASC')->get(); $pet_types = PetTypes::orderBy('pet_name', 'ASC')->get(); foreach ($pet_types as $row) { $a_service_name = array(); foreach ($service_available as $sub_row) { $a_pet_id = explode(",", $sub_row->pet_type_ids); if ($sub_row->pet_type_ids != '' && in_array($row->id, $a_pet_id)) { $a_service_name[] = $sub_row->service_name; } } $a_service_available[$row->pet_name] = $a_service_name; } //echo "<pre>"; print_r($a_service_available); die; return View::make('service_available')->with('a_service_available', $a_service_available); }