join('objects', 'properties.object_id', '=', 'objects.id') ->join('object_translations', 'objects.id', '=', 'object_translations.object_id') ->join('statuses', 'properties.status_id', '=', 'statuses.id') ->join('status_translations', 'statuses.id', '=', 'status_translations.status_id') ->select(['properties.id', 'property_translations.title', 'object_translations.title as object', 'status_translations.title as status']) ->where('property_translations.locale', app()->getLocale()) ->where('object_translations.locale', app()->getLocale()) ->where('status_translations.locale', app()->getLocale())) ->addColumn('options', function ($model) { return View::make('partials.options', compact('model'))->render(); }) ->filter(function ($query) { if(Request::has('search') && isset(Request::input('search')['value']) && !empty(Request::input('search')['value'])){ $search_term = Request::input('search')['value']; $query->whereTranslationLike('title', "%". $search_term . "%"); } }) ->make(true); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return view('property.index'); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('property.create', ['property' => new Property]); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CreatePropertyRequest $request) { $property = Property::create($request->all()); return redirect()->route('admin.property.edit', $property); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(Property $property) { $floor = $property->floor; $object = $property->object; return view('public.property', compact('property', 'floor', 'object')); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit(Property $property) { return view('property.edit', compact('property')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(UpdatePropertyRequest $request, Property $property) { $property->update($request->all()); return redirect()->route('admin.property.index'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(Property $property) { $property->delete(); } public function room(Property $property) { $property->rooms()->delete(); foreach((array) Request::input('rooms') as $room) { $property->rooms()->save(new Room($room)); } return redirect()->route('admin.property.edit', $property); } }