function showPropiedad($id) { $pictures = DB::table('pictures')->where('property_id', $id)->get(); $property = Property::find($id); if (!$property) { return Redirect::to("/"); } switch ($property->type) { case "Casas": $options = array("plural" => "Casas", "singular" => "Casa", 'icon' => 'home', 'color' => '#32A20E'); break; case "Terrenos": $options = array("plural" => "Terrenos", "singular" => "Terreno", 'icon' => 'tree-deciduous', 'color' => '#32A20E'); break; case "Locales": $options = array("plural" => "Locales", "singular" => "Local", 'icon' => 'gift', 'color' => '#FF0444'); break; default: $options = array("plural" => "Terrenos", "singular" => "Terreno", 'icon' => 'tree-deciduous', 'color' => '#32A20E'); } if ($property->oportunidad) { $options = array("plural" => "Oportunidades", "singular" => "Oportunidad", 'icon' => 'usd', 'color' => '#32A20E'); } return View::make('property_show', array('property' => $property, 'pictures' => $pictures, 'options' => $options)); }
public function photos($id) { $property = $this->property->find($id); if (is_null($property)) { return Redirect::to('admin/properties'); } return View::make('admin.properties.photos', array('property_id' => $id)); }
/** * Show the form for editing the specified kin. * * @param int $id * @return Response */ public function edit($id) { $property = Property::find($id); $user = User::findOrFail($property->issued_by); if ($property->received_by > 0) { $retuser = User::findOrFail($property->received_by); } return View::make('properties.edit', compact('property', 'user', 'retuser')); }
public function update_post($property_id, $id) { if (is_null(Property::find($property_id)) && is_null(Monitoring::find($id))) { return Redirect::to('admin/properties')->with('error', 'Property was not found.'); } $monitoring = Monitoring::find($id); $property = Property::find($property_id); $validator = Validator::make(Input::all(), Monitoring::$rules); if ($validator->fails()) { return Redirect::to(URL::current())->withErrors($validator)->withInput(); } else { $monitoring->property_id = $property_id; $monitoring->block = Input::get('block'); $monitoring->lot = Input::get('lot'); $monitoring->status = Input::get('status'); $monitoring->save(); return Redirect::to(URL::current())->with('success', 'Block has been saved'); } }
public function destroy($id) { Property::find($id)->delete(); House::where('propertyID', $id)->delete(); House::where('propertyID', $id)->delete(); Housedue::where('propertyID', $id)->delete(); return Redirect::route('admin.property.index'); }
public function reserve_post($id) { $property = Property::find($id); $admin_email = User::find(1)->email; $developer_email = $property->developer->email; if (is_null($property)) { return App::abort(404); } $validator = Validator::make(Input::all(), Reservation::$rules); if ($validator->passes()) { // REMOVE PROPERTY FROM THE LIST BECAUSE ITS ALREADY BEEN RESERVED $property->status = 0; $property->save(); // EMAIL DEVELOPER $reservation = new Reservation(); $reservation->property_id = $id; $reservation->firstname = Input::get('firstname'); $reservation->lastname = Input::get('lastname'); $reservation->phone = Input::get('phone'); $reservation->mobile = Input::get('mobile'); $reservation->home_address = Input::get('home_address'); $reservation->work_address = Input::get('work_address'); $reservation->work = Input::get('work'); $reservation->company = Input::get('company'); $reservation->tin_number = Input::get('tin_number'); $reservation->terms = Input::get('terms'); $reservation->email = Input::get('email'); $reservation->unit_type = Input::get('unit_type'); $reservation->save(); // CREATE NEW TRANSACTION $transaction = new Transaction(); $transaction->reference_number = date('Ymd') . '-' . str_random(5); $transaction->property_id = $id; $transaction->reservation_id = $reservation->id; $transaction->status = 'Pending'; $transaction->amount = $property->reservation_fee; $transaction->firstname = $reservation->firstname; $transaction->lastname = $reservation->lastname; $transaction->contact_number = $reservation->mobile; $transaction->address = $reservation->home_address; $transaction->email = $reservation->email; $transaction->remarks = "Reservation Fee"; $transaction->save(); // GENERATE INVOICE $html = View::make('admin.transactions.show', compact('transaction')); $pdf = storage_path() . '/invoices/' . $transaction->reference_number . '.pdf'; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $output = $dompdf->output(); file_put_contents($pdf, $output); // EMAIL THE INVOICE $data['transaction'] = $transaction; Mail::send('mails.default', $data, function ($message) use($transaction, $pdf) { $message->to($transaction->email)->subject("Your Invoice"); $message->attach($pdf); }); // EMAIL DEVELOPER AND ADMINISTRATOR $data['property'] = $property; $data['firstname'] = Input::get('firstname'); $data['lastname'] = Input::get('lastname'); $data['phone'] = Input::get('phone'); $data['mobile'] = Input::get('mobile'); $data['tin_number'] = Input::get('tin_number'); $data['home_address'] = Input::get('home_address'); $data['work_address'] = Input::get('work_address'); $data['work'] = Input::get('work'); $data['company'] = Input::get('company'); $data['terms'] = Input::get('terms'); $data['email'] = Input::get('email'); $data['unit_type'] = Input::get('unit_type'); Mail::send('mails.reservation', $data, function ($message) use($admin_email, $developer_email) { $message->to($admin_email, 'Live and Love')->subject('Property Reservation'); if ($developer_email) { $message->to($developer_email, 'Live and Love')->subject('Property Reservation'); } }); return Redirect::to('properties/reserve/' . $id)->with('success', 'Email has been sent to administrator. Well send you an invoice for billing the reservation fee.'); } else { return Redirect::to('properties/reserve/' . $id)->withErrors($validator)->withInput(); } }
public function test_should_include_associates_using_simple_finder() { $Property = new Property(); $PropertyType = new PropertyType(); $this->assertTrue($Rancho =& $PropertyType->findFirstBy('description', 'Rancho Type', array('include' => 'properties'))); $this->assertTrue($RanchoMaria =& $Property->find($Rancho->properties[0]->getId(), array('include' => 'property_types'))); $this->assertEqual($RanchoMaria->property_types[0]->getId(), $Rancho->getId()); $this->assertEqual($RanchoMaria->getId(), $Rancho->properties[0]->getId()); }
/** * Show the form for editing the specified property. * * @param int $id * @return Response */ public function getEdit($id) { $property = Property::find($id); return View::make('properties.edit', compact('property')); }
public static function get_computation($id, $size = array(200, 200)) { $timthumb = URL::to('photos') . '/timthumb.php?src='; $computation = Property::find($id); if (empty($computation->computation)) { return $timthumb . URL::to('photos') . '/default.jpg&w=' . $size[0] . '&h=' . $size[1]; } else { return $timthumb . URL::to('photos') . '/computations/' . $computation->computation . '&w=' . $size[0] . '&h=' . $size[1]; } }
public function getMail($id) { $prop = Property::find($id)->toArray(); $tmpl = Template::where('type', 'brochure')->where('status', 'active')->first(); $template = $tmpl->template; //$content = View::make('print.brochure')->with('prop',$prop)->render(); $brochurepdf = PDF::loadView('brochuretmpl.' . $template, array('prop' => $prop))->setOption('margin-top', '0mm')->setOption('margin-left', '0mm')->setOption('margin-right', '0mm')->setOption('margin-bottom', '0mm')->setOption('dpi', 200)->setPaper('A4')->output(); file_put_contents(public_path() . '/storage/pdf/' . $prop['propertyId'] . '.pdf', $brochurepdf); //$mailcontent = View::make('emails.brochure')->with('prop',$prop)->render(); Mail::send('emails.brochure', $prop, function ($message) use($prop, &$prop) { $to = Input::get('to'); $tos = explode(',', $to); if (is_array($tos) && count($tos) > 1) { foreach ($tos as $to) { $message->to($to, $to); } } else { $message->to($to, $to); } $message->subject('Investors Alliance - ' . $prop['propertyId']); $message->cc('*****@*****.**'); $message->attach(public_path() . '/storage/pdf/' . $prop['propertyId'] . '.pdf'); }); print json_encode(array('result' => 'OK')); }
public function reserve_post($id) { // GET THE LAST RESERVATION $last_user_reservation = Reservation::where('user_id', Sentry::getUser()->id)->orderBy('created_at', 'desc')->first(); if (!is_null($last_user_reservation)) { $current_time = time(); $last_user_reservation_time = strtotime($last_user_reservation->created_at); $interval = abs($current_time - $last_user_reservation_time) / 3600; if ($interval < 15) { return Redirect::to('clients')->with('info', 'You must wait 15 hours before you can reserve again.'); } } if (is_null(Property::find($id))) { return Redirect::to('properties'); } $monitoring = Monitoring::where('block', Input::get('block'))->where('lot', Input::get('lot')) - first(); if (!is_null($monitoring) && $monitoring->status == false) { return Redirect::to('clients')->with('info', 'This s**t is not available sorry.'); } $rules = array('total_contract_price' => 'required', 'reservation_fee' => 'required', 'downpayment' => 'required', 'equity' => 'required', 'total_months' => 'required', 'monthly_fee' => 'required', 'agent_id' => 'required', 'terms' => 'required', 'block' => 'required|numeric', 'lot' => 'required|numeric'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('clients/reserve/' . $id)->withInput()->withErrors($validator); } else { $property = Property::find($id); $user = $this->user; // 0. CHANGE PROPERTY STATUS TO 0 $downpayment = intval(Input::get('downpayment')) / 100 * $property->price; $equity = $property->price - $downpayment - $property->reservation_fee; $total_months = intval(Input::get('total_months')); // 1. SAVE TO THE DATABASE $reservation = new Reservation(); $reservation->property_id = $id; $reservation->user_id = $this->user->id; $reservation->agent_id = Input::get('agent_id'); $reservation->total_contract_price = intval(Input::get('total_contract_price')); $reservation->downpayment = $downpayment; $reservation->reservation_fee = $property->reservation_fee; $reservation->block = Input::get('block'); $reservation->lot = Input::get('lot'); // LOANABLE AMOUNT $reservation->equity = $equity; $reservation->total_months = $total_months; $reservation->monthly_fee = $equity / $total_months; $reservation->terms = Input::get('terms'); //$reservation->unit_type = Input::get('unit_type'); $reservation->save(); // 2. NEW TRANSACTION $transaction = new Transaction(); $transaction->reference_number = date('Ymd') . '-' . strtoupper(str_random(5)); $transaction->property_id = $id; $transaction->user_id = $this->user->id; $transaction->reservation_id = $reservation->id; $transaction->status = 'Pending'; $transaction->amount = $property->reservation_fee; $transaction->remarks = "Property Reservation"; $transaction->save(); // UPDATE MONITORING DB::table('monitorings')->where('block', Input::get('block'))->where('lot', Input::get('lot'))->update(array('status' => false)); // 3.GENERATE INVOICE $x = View::make('admin.transactions.show', compact('transaction', 'user', 'property')); $pdf = storage_path() . '/invoices/' . $transaction->reference_number . '.pdf'; $dompdf = new DOMPDF(); $dompdf->load_html($x); $dompdf->render(); $output = $dompdf->output(); @file_put_contents($pdf, $output); // 3.1 GENERATE RESERVATION INFORMATION PDF $y = View::make('admin.reservations.pdf', compact('transaction', 'user', 'reservation', 'property')); $res = storage_path() . '/reservations/reservation-' . $transaction->reference_number . '.pdf'; $dompdf = new DOMPDF(); $dompdf->load_html($y); $dompdf->render(); $output = $dompdf->output(); @file_put_contents($res, $output); // 4. EMAIL DEVELOPER,ADMIN AND BUYER $admin = User::find(1); $developer = $property->developer; $data['transaction'] = $transaction; Mail::send('mails.default', $data, function ($message) use($transaction, $pdf, $developer, $admin, $res) { $user = Sentry::getUser(); $message->to($user->email)->subject("Property Reservation Notification"); $message->to($developer->email)->subject("Property Reservation Notification"); $message->to($admin->email)->subject("Property Reservation Notification"); $message->attach($pdf); $message->attach($res); }); return Redirect::to('clients')->with('success', 'Your reservation has been sent to administrator for approval.'); } }
public function postUnassign() { $in = Input::get(); $user_id = $in['user_id']; $prop_ids = $in['prop_ids']; foreach ($prop_ids as $p) { $prop = Property::find($p); if ($prop) { $prop->pull('assigned_user', $user_id); $prop->save(); } } return Response::json(array('result' => 'OK')); }
//$queries = DB::getQueryLog(); //var_dump($queries); $options = array("plural" => "Complejos", "singular" => "Complejo", 'icon' => 'home', 'color' => '#32A20E', 'tipo' => 'resultados_busqueda'); return View::make('properties_list', array('properties' => $resultados, 'options' => $options)); }); Route::group(array('prefix' => 'Villa_General_Belgrano'), function () { Route::get('/Propiedad/{id}/{nombre}', array('as' => 'showPropiedad', 'uses' => 'PropertiesController@showPropiedad')); Route::post('/Propiedad/{id}/{nombre}', function ($id, $nombre) { $rules = array('nombre' => 'required|min:3', 'telefono' => 'required|min:5', 'email' => 'required|email', 'consulta' => 'required|min:5'); $messages = array('required' => 'El campo :attribute es obligatorio', 'email' => 'El email ingresado no es válido', 'min' => 'El campo :attribute debe tener al menos :min caracteres'); $validator = Validator::make(Input::all(), $rules, $messages); if ($validator->fails()) { return Redirect::to("Villa_General_Belgrano/Propiedad/{$id}/{$nombre}")->withErrors($validator)->withInput(); } else { $input = Input::all(); $property = Property::find($id); $input = array('nombre' => $input['nombre'], 'telefono' => $input['telefono'], 'email' => $input['email'], 'consulta' => $input['consulta'], 'propiedad' => $property->name, 'id' => $property->id, 'operation' => $property->operation); Mail::send('emails.consultaPropiedad', $input, function ($message) use($input) { $message->from('*****@*****.**', 'Sitio Web'); $message->to('*****@*****.**', 'Falcione Vega')->subject('Consulta en Inmobiliaria FalcioneVega')->replyTo($input['email'], $input['nombre']); if ($input['operation'] == 'Alquiler Permanente' || $input['operation'] == 'Alquiler Temporario') { $message->cc('*****@*****.**', 'Pablo Ariel Cerbino'); $message->cc('*****@*****.**', 'Laura Olmedo..'); } }); Session::flash('emailSended', 1); return Redirect::to("Villa_General_Belgrano/Propiedad/{$id}/{$nombre}"); } }); Route::get('/Casas', array('as' => 'casas', 'uses' => 'PropertiesController@listCasas')); Route::get('/Locales', array('as' => 'locales', 'uses' => 'PropertiesController@listLocales'));
/** * Remove the specified resource from storage. * DELETE /properties/{id} * * @param int $id * @return Response */ public function destroy($id) { Property::find($id)->delete(); return Redirect::route('admin.property'); }