public function run() { Model::unguard(); DB::table('company_types')->truncate(); CompanyType::create(['name' => 'Restaurant', 'status' => '1']); CompanyType::create(['name' => 'Distribuidor', 'status' => '1']); CompanyType::create(['name' => 'Cliente', 'status' => '1']); CompanyType::create(['name' => 'Otro', 'status' => '1']); }
<th>n°</th> <th>Empresa</th> <th>Email</th> <th>Tipo</th> <th></th> </tr> </thead> <tbody> @foreach($companies as $index=>$company) <tr> <td>{{$index+1}}</td> <td>{{$company->name}}</td> <td>{{$company->email}}</td> <td>@if(isset($company->company_type_id)) <?php $company_type = \Pronueva_back\CompanyType::where('id', $company->company_type_id)->first(); ?> {{$company_type['name']}} @endif</td> <td><a href="{{URL::to($module.'/delete/'.$company->id)}}" class="btn btn-3d btn-sm btn-reveal btn-red"> <i class="glyphicon glyphicon-minus"></i> <span>Eliminar</span> </a> <a href="{{URL::to($module.'/edit/'.$company->id)}}" class="btn btn-3d btn-sm btn-reveal btn-info"> <i class="glyphicon glyphicon-pencil"></i> <span>Editar</span> </a> </td> </tr> @endforeach </tbody> </table>
public function edit($id) { $data['module'] = $this->module; $data['module_name'] = $this->module_name; $company = $this->company; $data['company'] = $company::where('id', $id)->first(); $data['sub_module'] = 'Editar Empresa'; $data['compay_types'] = array('0' => 'Seleccionar') + CompanyType::Active()->lists('name', 'id'); $data['action'] = 'update/'; return view('accounts.companies.edit', $data); }