/** * Show the application dashboard to the user. * * @return Response */ public function index() { $articles = Article::with('author')->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get(); // TODO: abstract to model $sliders = Photo::join('photo_albums', 'photo_albums.id', '=', 'photos.photo_album_id')->where('photos.slider', 1)->orderBy('photos.position', 'DESC')->orderBy('photos.created_at', 'DESC')->select('photos.filename', 'photos.name', 'photos.description', 'photo_albums.folder_id')->get(); $photoAlbums = PhotoAlbum::select(array('photo_albums.id', 'photo_albums.name', 'photo_albums.description', 'photo_albums.folder_id', DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id LIMIT 1) AS album_image'), DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get(); $videoAlbums = VideoAlbum::select(array('video_albums.id', 'video_albums.name', 'video_albums.description', 'video_albums.folder_id', DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id LIMIT 1) AS album_image'), DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get(); $categoriesArray = Object::where('type', 'category')->get(); $categories = array(); foreach ($categoriesArray as $category) { $categories[] = array($category->title); } $categories = Object::where('type', 'category')->get(); global $types; $types = Object::getTypes()->select(array('id', DB::raw("REPLACE(name, '_object_type_', '') as name"), DB::raw("REPLACE(title, 'Object Type: ', '') as title"), 'created_at'))->get(); return view('pages.home', compact('articles', 'sliders', 'videoAlbums', 'photoAlbums', 'categories', 'types')); //return view('pages.welcome'); }
/** * Show the form for creating a new resource. * * @return Response */ public function getCreate() { if ($typeName = Input::get('type')) { if ($type = Object::getType($typeName)->first()) { $fieldsRows = Object::getFields($type->id)->get(); $fields = array(); $fieldControls = array(); // Occupation $field = array(); $field['id'] = '_field_occupation'; $field['name'] = 'occupation'; $field['label'] = 'Occupation'; $field['type'] = 'text'; $field['instructions'] = ''; $field['required'] = 0; $fieldControls[] = view('admin.partials.form.text', compact('field')); // Address $uniqueId = Hash::getUniqueId(); $field = array(); $field['id'] = '_field_address'; $field['name'] = 'address'; $field['label'] = 'Address'; $field['type'] = 'map'; $field['instructions'] = ''; $field['required'] = 0; $fieldControls[] = view('admin.partials.form.map', compact('field', 'uniqueId')); // French $field = array(); $field['id'] = '_field_french_speakers'; $field['name'] = 'french_speakers'; $field['label'] = 'French Speakers'; $field['type'] = 'boolean'; $field['instructions'] = ''; $field['required'] = 0; $fieldControls[] = view('admin.partials.form.boolean', compact('field')); // Address $field = array(); $field['id'] = '_field_phone'; $field['name'] = 'phone'; $field['label'] = 'Phone'; $field['type'] = 'tel'; $field['instructions'] = ''; $field['required'] = 0; $fieldControls[] = view('admin.partials.form.tel', compact('field')); // Email $field = array(); $field['id'] = '_field_email'; $field['name'] = 'email'; $field['label'] = 'Email'; $field['type'] = 'email'; $field['instructions'] = ''; $field['required'] = 0; $fieldControls[] = view('admin.partials.form.email', compact('field')); foreach ($fieldsRows as $fieldRow) { $field = unserialize($fieldRow['meta_value']); $fields[] = $field; $uniqueId = Hash::getUniqueId(); switch ($field['type']) { case 'text': $fieldControls[] = view('admin.partials.form.text', compact('field', 'uniqueId')); break; case 'wysiwyg': $fieldControls[] = view('admin.partials.form.wysiwyg', compact('field', 'uniqueId')); break; case 'map': $fieldControls[] = view('admin.partials.form.map', compact('field', 'uniqueId')); break; case 'tel': $fieldControls[] = view('admin.partials.form.tel', compact('field', 'uniqueId')); break; case 'boolean': $fieldControls[] = view('admin.partials.form.boolean', compact('field', 'uniqueId')); break; } } } } $types = Object::getTypes()->select(array('id', DB::raw("REPLACE(name, '_object_type_', '') as name"), DB::raw("REPLACE(title, 'Object Type: ', '') as title"), 'created_at'))->get(); return view('admin.object.create_edit', compact('fields', 'fieldControls', 'featuredImage', 'contentImage', 'types')); }
/** * Show a list of all the languages posts formatted for Datatables. * * @return Datatables JSON */ public function data() { $objecttypes = Object::getTypes()->select(array('id', DB::raw("REPLACE(title, 'Object Type: ', '') as title"), 'status', 'created_at')); // ObjectType::select(array('object_types.id','object_types.name','object_types.display_name', 'object_types.created_at')); return Datatables::of($objecttypes)->add_column('actions', '@if ($id>"4")<a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/edit\' ) }}}" class="btn btn-success btn-sm" ><span class="glyphicon glyphicon-pencil"></span> {{ trans("admin/modal.edit") }}</a> <a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/delete\' ) }}}" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span> {{ trans("admin/modal.delete") }}</a> <a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/export?format=excel\' ) }}}" class="btn btn-sm btn-primary"><span class="glyphicon glyphicon-export"></span> {{ trans("admin/admin.export") }}</a> @endif')->remove_column('id')->make(); // $objecttypes = ObjectType::select(array('object_types.id','object_types.name','object_types.display_name', 'object_types.created_at')); // // return Datatables::of($objecttypes) // ->add_column('actions', '@if ($id>"4")<a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/edit\' ) }}}" class="btn btn-success btn-sm" ><span class="glyphicon glyphicon-pencil"></span> {{ trans("admin/modal.edit") }}</a> // <a href="{{{ URL::to(\'admin/object-types/\' . $id . \'/delete\' ) }}}" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span> {{ trans("admin/modal.delete") }}</a> // @endif') // ->remove_column('id') // // ->make(); }