public function contact() { $title = 'Contact'; $name = App::getLocale() == 'fr' ? 'name_fr' : 'name_en'; if (App::getLocale() == 'fr') { $iams = [1 => 'Indépendant', 2 => 'Particulier', 3 => 'Organisme public']; } else { $iams = [1 => 'Professional client', 2 => 'Private client', 3 => 'Public body']; } $objects = Object::lists($name, 'id'); return view('pages.contact', compact('title', 'objects', 'iams')); }
/** * 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'); }
public function getSearch() { $categoryId = Input::get('categoryid'); $search = Input::get('query'); $objects = null; if ($categoryId) { // Category Image if ($featuredImageId = ObjectMeta::getValue($categoryId, '_featured_image')) { $featuredImageUrl = getImageSrc($featuredImageId, 'thumbnail'); } // Get objects where in category $objects = Object::Where('type', 'object_type')->whereExists(function ($query) use($categoryId) { $query->select(DB::raw(1))->from('object_meta')->whereRaw(DB::getTablePrefix() . 'object_meta.object_id = ' . DB::getTablePrefix() . 'objects.id')->where('meta_key', '_category_id')->where('meta_value', $categoryId); })->select(DB::raw('substr(name, 14) as field_name'))->get()->toArray(); $types = array_map(function ($v) { return $v['field_name']; }, $objects); if (!empty($types)) { $objects = Object::whereIn('type', $types); } } if ($objects) { $objects = $objects->select(array('objects.id', DB::raw('"/uploads/' . $featuredImageUrl . '"' . ' as featured_image'), 'objects.name', 'objects.title', 'objects.excerpt'))->get(); } return $objects; }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $mail = Mail::findOrFail($id); $objects = Object::lists('name_fr', 'id'); $title = 'Editer l\'adresse e-mail "' . $mail->email . '"'; return view('admin.mails.edit', compact('title', 'mail', 'objects')); }
public function delete($id) { try { return Object::destroy($id); } catch (\Exception $e) { return ['error' => $e->getMessage()]; } }
/** * Show the object list to the user. * * @return Response */ function getIndex() { $grid = DataGrid::source(Object::with('partner')); $grid->add('name', 'Name', true); $grid->add('{{ (string)$partner }}', 'Partner'); $grid->add('address2', 'Ort', true); $grid->add('address1', 'Strasse', true); $grid->edit(url('/object/edit'), '', 'show'); $grid->paginate(10); return view('grid', compact('grid')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $app = Application::findOrFail($id); $app->key = $app->key ?: $this->app_key(); $app->private = $app->private ?: $this->app_key(); $objects = Object::get(); $objects_perms = []; $perms = $app->objects; if ($perms) { $perms = unserialize($perms); foreach ($objects as $object) { $oid = $object->id; if (isset($perms['OBJ' . $oid])) { $object->permissions = $perms['OBJ' . $oid]; } } } return view('record/application', ['table' => 'apps', 'application' => $app, 'title' => 'Applications', 'subtitle' => 'Edit ' . $app->name, 'objects' => $objects]); }
public function update($sessionId, $objects) { foreach ($objects as $object) { $gameObject = \App\Object::where('session_id', '=', $sessionId)->where('log', '=', $object['name'])->first(); if (is_null($gameObject)) { continue; } // there is no status 0 - its a C! if ($object['status'] == '0' && !starts_with($object['name'], 'BMA')) { $object['status'] = 'C'; } // status 9 means patrol for police which // means free on radio if ($object['status'] == '9') { $object['status'] = '1'; } $gameObject->status = $object['status']; $gameObject->save(); } return $sessionId; }
function anyEdit(Request $request) { $object = null; $edit = DataEdit::source(new Photo()); if ($edit->status == 'show') { $edit->link(url('/photo/note?noteable_id=' . $edit->model->id), 'notiz anlegen', 'BR'); } // Add Object reference if ($request->has('object_id')) { $object = Object::find($request->get('object_id')); if ($object instanceof Object) { $edit->model->object_id = $object->id; } else { throw new \Exception("Invalid call to create photo"); } } else { $object = $edit->model->object; } $edit->link(url('/object/edit?show=' . $object->id), 'abbrechen', 'TR')->back(); $edit->add('photo', 'Foto', 'image')->move(Object::BasePath . $object->id . '/photo/')->fit(1024, 1024)->preview(256, 256); $edit->add('dummy1', 'Standort', 'text')->insertValue($object ? $object : null)->updateValue($object ? $object : null)->showValue($object ? $object : null)->attributes(['readonly' => 'readonly']); return $edit->view('edit.photo', compact('edit')); }
public function update($sessionId, $objects) { foreach ($objects as $object) { $gameObject = \App\Object::where('session_id', '=', $sessionId)->where('log', '=', $object['name'])->first(); if (is_null($gameObject)) { continue; } // there is no status 0 - its a C! if ($object['status'] == '0' && !starts_with($object['name'], 'BMA')) { $object['status'] = 'C'; } // status 9 means patrol for police which // means free on radio if ($object['status'] == '9') { $object['status'] = '1'; } $client = new \phpcent\Client(env('CENT_HOST')); $client->setSecret(env('CENT_SECRET')); $client->publish($sessionId, ['payload' => $object, 'id' => $gameObject->id]); $gameObject->status = $object['status']; $gameObject->save(); } return $sessionId; }
echo '<td>' . $item['type'] . '</td>'; echo '<td>' . $item['title'] . '</td>'; echo '<td style="text-align: center"><a href="' . url("admin/objects/{$item['id']}/edit") . '">' . $item['id'] . '</a></td>'; echo '</tr>'; } echo '</tbody>'; echo '<table>'; echo '<style>td{padding: 2px 5px;}</style><pre>'; break; default: die('Please pass a type (address / coordinates)'); } }); Route::get('/fixAddresses', function () { ini_set('max_execution_time', 300); $list = \App\Object::whereNotIn('objects.type', ['image', 'category'])->join('object_meta as om', function ($join) { $join->on('om.object_id', '=', 'objects.id'); })->where(function ($where) { $where->where('om.meta_key', '=', '_field_address-address')->orWhere('om.meta_key', '=', '_field_address-city')->orWhere('om.meta_key', '=', '_field_address-country')->orWhere('om.meta_key', '=', '_field_address-location-g')->orWhere('om.meta_key', '=', '_field_address-location-k'); })->select('om.id', 'om.object_id', 'om.meta_key', 'om.meta_value')->orderBy('om.object_id', 'ASC'); $limit = isset($_GET['limit']) ? intval($_GET['limit']) : false; $offset = isset($_GET['offset']) ? intval($_GET['offset']) : false; $print = isset($_GET['print']) ? true : false; if (!$limit) { die('You did not send a limit'); } $items = array(); foreach ($list->get() as $item) { $items[$item->object_id][$item->meta_key] = array('id' => $item->id, 'value' => $item->meta_value); } $items = array_slice($items, $offset, $limit, true);
public function getCategoryObjects($id = null) { $objects = Object::join('object_meta', 'objects.id', '=', 'object_meta.object_id')->where('object_meta.meta_key', '_category_id')->where('object_meta.meta_value', $id)->where('objects.type', '<>', 'category')->select(array('objects.id', 'objects.name', 'objects.title'))->get(); return $objects; }
public function getContent($id) { if ($id) { if ($object = Object::find($id)) { return $object->content; } } }
/** * Fetches active roles * * @param Object $query Query object * * @return Object */ public function scopeActive($query) { return $query->where('isActive', '=', '1'); }
function addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, $fieldName) { list($source_image_width, $source_image_height, $source_image_type) = getimagesize($destinationPath . $picture); $imageObjectInfo = array(); $imageObjectInfo['width'] = $source_image_width; $imageObjectInfo['height'] = $source_image_height; $imageObjectInfo['fileName'] = $filename; $imageObjectInfo['filePath'] = $newfileName . '.' . $extension; $imageObjectInfo['sizes'] = array(); $x = autoCrop($destinationPath, $picture, $fieldName); if ($x !== false) { $round = (int) \App\ResizesTinypng::max('round') + 1; insertIntoTableResizes($round, getTheImageSize($picture, $fieldName), $destinationPath . 'cropped/' . getTheImageSize($picture, $fieldName), 0, 'N', 0, false); $results_table = selectByRoundNumber($round); if (!empty($results_table)) { foreach ($results_table as $res_row) { $result_array = array('id' => intval($res_row['id']), 'round' => intval($res_row['round']), 'filename' => $res_row['file_name'], 'path' => $res_row['path'], 'runTiny' => intval($res_row['run_tiny']), 'error' => $res_row['error'], 'timeTiny' => intval($res_row['time_tiny']), 'timeAdded' => intval($res_row['created_at'])); $row_obj = array_to_object($result_array); $error_message = "N"; //START >> tinify images $tmp_path = str_replace(getcwd() . '/', "", $row_obj->path); //GET SERVER PATH $save_path = str_replace($row_obj->filename, "", $tmp_path); //OVERRIDE CURRENT LOCATION $flag = tinifyImage($row_obj->path, $save_path); if ($flag === false) { if ($error_message == "N") { $error_message = "Y - Compression failed"; } else { $error_message .= " - Compression failed"; } } //END << tinify image //UPDATE DB updateTableResizes($row_obj->id, $row_obj->round, $row_obj->filename, $row_obj->path, 1, $error_message, time(), $row_obj->timeAdded); } } } /* if ($source_image_width > 1920) {//} || $source_image_height > 1080) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.'. $extension, 1920, 1080); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.'. $extension); rename( $destinationPath . $newfileName . '-resized.'. $extension, $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension); $imageInfo = array(); $imageInfo['fileName'] = $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['large'] = $imageInfo; } if ($source_image_width > 1024) { // || $source_image_height > 768) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.'. $extension, 1024, 768); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.'. $extension); rename( $destinationPath . $newfileName . '-resized.'. $extension, $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['medium'] = $imageInfo; } if ($source_image_width > 350) {//|| $source_image_height > 350) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.'. $extension, 350, 350); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.'. $extension); rename( $destinationPath . $newfileName . '-resized.'. $extension, $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['small'] = $imageInfo; } if ($source_image_width > 300) {//|| $source_image_height > 350) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.'. $extension, 300, 300); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.'. $extension); rename( $destinationPath . $newfileName . '-resized.'. $extension, $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['thumbnail'] = $imageInfo; } */ // Save image object if ($imageObjectId = ObjectMeta::getValue($object->id, $fieldName)) { $imageObject = Object::find($imageObjectId); } if (empty($imageObject)) { $imageObject = new Object(); } $imageObject->author_id = Auth::user()->id; $imageObject->type = 'image'; $imageObject->name = $newfileName . '.' . $extension; $imageObject->title = $filename; $imageObject->status = 'inherit'; $imageObject->guid = $newfileName; $imageObject->save(); ObjectMeta::setValue($imageObject->id, '_file_path', $newfileName . '.' . $extension); ObjectMeta::setValue($imageObject->id, '_image_info', serialize($imageObjectInfo)); ObjectMeta::setValue($object->id, $fieldName, $imageObject->id); return $imageObject; }
public function getExport($id) { if ($objectType = Object::find($id)) { if ($data = ObjectType::getFields($id)->get()) { $fields = array(); $fields[] = 'name'; $fields[] = 'title'; $fields[] = 'content'; $fields[] = 'occupation'; $fields[] = 'address'; $fields[] = 'french_speakers'; $fields[] = 'phone'; $fields[] = 'email'; foreach ($data as $field) { $fieldInfo = unserialize($field->meta_value); $fields[] = $fieldInfo['name']; } if ($format = Input::get('format')) { switch ($format) { case 'excel': Excel::create(str_replace('Object Type: ', '', $objectType['title']), function ($excel) use($objectType, $fields) { $excel->sheet(str_replace('Object Type: ', '', $objectType['title']), function ($sheet) use($fields) { $sheet->setOrientation('landscape'); $sheet->fromArray($fields); }); })->export('xls'); break; } } } } }
* List of photos */ function photos() { return $this->hasMany('App\\Photo', 'object_id'); } /** /** * Connect to Partner */ function partner() { return $this->belongsTo('App\\Partner'); } /** * Connect to Zipcode */ function zipcode() { return $this->belongsTo('App\\Geodata\\Zipcode'); } /** * */ function __toString() { return $this->name; } } Object::observe(new BlameableObserver());
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Object::findOrFail($id)->delete(); return redirect('/objects'); }
public function getCategories($id = null) { //Config::set('laravel-debugbar::config.enabled', false); $categories = Object::where('type', 'category')->where('parent_id', $id)->get(); return response()->json($categories); }
protected function getObject() { return \App\Object::where('status', \App\Object::STATUS_NEW)->orderBy('created_at')->first(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Object::destroy($id); return redirect(route('admin.objects.index'))->with('success', 'L\'objet a bien été supprimé'); }
public function getFields($id) { //$object = Object::find($id); $fields = Object::getFields($id)->select(array('id', 'meta_key', 'meta_value', 'created_at')); // object::select(array('object_types.id','object_types.name','object_types.display_name', 'object_types.created_at')); // $output = array(); // // foreach ($fields as $field) { // $fieldInfo = unserialize($field['meta_value']); // // $output[] = array( // 'label' => $fieldInfo['label'] // ); // } // // $table = Datatable::table() // ->addColumn('Name', 'Last Login', 'View') // ->setUrl(route('api.users')) // ->noScript(); return Datatables::of($fields)->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(); }
function anyEdit(Request $request) { $partner = null; $object = null; $edit = DataEdit::source(new Task()); if ($edit->status == 'create') { $edit->link(url('/task'), 'abbrechen', 'TR')->back(); } if ($edit->status == 'show') { $edit->link(url('/task/note?noteable_id=' . $edit->model->id), 'notiz anlegen', 'BR'); } if ($edit->status == 'modify') { $edit->link(url('/task/edit?delete=' . $edit->model->id), 'löschen', 'TR'); } // Add Partner reference if ($request->has('partner_id')) { $partner = Partner::find($request->get('partner_id')); if ($partner instanceof Partner) { $edit->model->partner_id = $partner->id; } } else { if ($request->has('object_id')) { $object = Object::find($request->get('object_id')); if ($object instanceof Object) { $edit->model->object_id = $object->id; $edit->model->partner_id = $object->partner_id; $partner = $object->partner; } } else { $partner = $edit->model->partner; $object = $edit->model->object; } } $edit->add('name', 'Aufgabe', 'text')->attributes(['class' => 'autofocus'])->rule('required'); $edit->add('assigned_to', 'Verantwortlich', 'select')->options([null => '-- Nicht zugeordnet --'] + User::lists("name", "id")); if ($edit->status == 'create') { $edit->add('note', 'Details', 'textarea'); } else { if ($edit->status == 'modify') { $edit->add('is_finished', 'Erledigt', 'checkbox'); } else { if ($edit->status == 'show') { // Display Partner $edit->add('dummy3', 'Erledigt', 'text')->showValue($edit->model->is_finished ? 'ja' : 'nein')->attributes(['readonly' => 'readonly']); } } } $begin_at = date('Y-m-d'); $edit->add('begin_at', 'Start', 'date')->format('Y-m-d')->insertValue($begin_at)->showValue($begin_at)->rule('required'); $finish_at = date('Y-m-d', strtotime('+1 week')); $edit->add('finish_at', 'Ende', 'date')->format('Y-m-d')->insertValue($finish_at)->showValue($finish_at)->rule('required'); $duration = $edit->model->duration; $edit->add('dummy4', 'Dauer', 'text')->showValue($duration)->attributes(['readonly' => 'readonly']); $duein = $edit->model->duein; $edit->add('dummy5', 'Fällig', 'text')->showValue($duein)->attributes(['readonly' => 'readonly']); // Display Partner $edit->add('dummy1', 'Partner', 'text')->insertValue($partner ? $partner : null)->updateValue($partner ? $partner : null)->showValue($partner ? $partner : null)->attributes(['readonly' => 'readonly']); // Display Object $edit->add('dummy2', 'Standort', 'text')->insertValue($object ? $object : null)->updateValue($object ? $object : null)->showValue($object ? $object : null)->attributes(['readonly' => 'readonly']); $edit->saved(function () use($edit) { // Create a note for details if ($edit->status == 'create') { $text = isset($edit->fields['note']) ? trim($edit->fields['note']->value) : ''; if (strlen($text) > 0) { $note = new Note(['text' => $text]); $edit->model->notes()->save($note); } } }); return $edit->view('task', compact('edit')); }
public static function getType($name) { return Object::where('name', '=', "_object_type_{$name}"); }
function addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, $fieldName) { list($source_image_width, $source_image_height, $source_image_type) = getimagesize($destinationPath . $picture); $imageObjectInfo = array(); $imageObjectInfo['width'] = $source_image_width; $imageObjectInfo['height'] = $source_image_height; $imageObjectInfo['filePath'] = $filename; $imageObjectInfo['sizes'] = array(); if ($source_image_width > 1920) { //} || $source_image_height > 1080) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.' . $extension, 1920, 1080); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.' . $extension); rename($destinationPath . $newfileName . '-resized.' . $extension, $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension); $imageInfo = array(); $imageInfo['fileName'] = $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['large'] = $imageInfo; } if ($source_image_width > 1024) { // || $source_image_height > 768) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.' . $extension, 1024, 768); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.' . $extension); rename($destinationPath . $newfileName . '-resized.' . $extension, $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['medium'] = $imageInfo; } if ($source_image_width > 350) { //|| $source_image_height > 350) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.' . $extension, 350, 350); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.' . $extension); rename($destinationPath . $newfileName . '-resized.' . $extension, $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['small'] = $imageInfo; } if ($source_image_width > 300) { //|| $source_image_height > 350) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.' . $extension, 300, 300); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.' . $extension); rename($destinationPath . $newfileName . '-resized.' . $extension, $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['thumbnail'] = $imageInfo; } // Save image object if ($imageObjectId = ObjectMeta::getValue($object->id, $fieldName)) { $imageObject = Object::find($imageObjectId); } if (empty($imageObject)) { $imageObject = new Object(); } $imageObject->author_id = Auth::user()->id; $imageObject->type = 'image'; $imageObject->name = $newfileName . '.' . $extension; $imageObject->title = $filename; $imageObject->status = 'inherit'; $imageObject->guid = $newfileName; $imageObject->save(); ObjectMeta::setValue($imageObject->id, '_file_path', $newfileName . '.' . $extension); ObjectMeta::setValue($imageObject->id, '_image_info', serialize($imageObjectInfo)); ObjectMeta::setValue($object->id, $fieldName, $imageObject->id); return $imageObject; }
public function run() { $xls = 'database/seeds/seeder.xlsm'; $book = Excel::load($xls, 'UTF-8')->all(); foreach ($book as $sheet) { if ($sheet->getTitle() === 'categories') { Category::truncate(); foreach ($sheet as $row) { $category = Category::create(['id' => $row->id, 'parent_id' => $row->parent_id, 'level' => $row->level, 'type' => $row->type, 'menutype' => $row->menutype, 'title' => $row->title, 'sef' => $row->sef, 'class' => $row->class, 'body' => $row->body, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc]); } } if ($sheet->getTitle() === 'furnitura') { Furnitura::truncate(); foreach ($sheet as $row) { if (!empty($row->category_id)) { $menu = Furnitura::create(['id' => $row->id, 'category_id' => $row->category_id, 'cat2_id' => $row->cat2_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'artikul' => $row->artikul, 'otdelka' => $row->otdelka, 'pcs' => $row->pcs, 'description' => $row->description, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]); } } } if ($sheet->getTitle() === 'links') { Link::truncate(); foreach ($sheet as $row) { if (!empty($row->category_id)) { $menu = Link::create(['category_id' => $row->category_id, 'title' => $row->title, 'url' => $row->url, 'description' => $row->description, 'version' => $row->version, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]); } } } if ($sheet->getTitle() === 'news') { News::truncate(); foreach ($sheet as $row) { if (!empty($row->category_id)) { $menu = News::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits, 'created_at' => $row->created_at]); } } } if ($sheet->getTitle() === 'steklo') { Page::truncate(); foreach ($sheet as $row) { if (!empty($row->category_id)) { $menu = Page::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]); } } } if ($sheet->getTitle() === 'uslugi') { Uslugi::truncate(); foreach ($sheet as $row) { if (!empty($row->category_id)) { $menu = Uslugi::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]); } } } if ($sheet->getTitle() === 'faq') { Faq::truncate(); foreach ($sheet as $row) { if (!empty($row->category_id)) { $menu = Faq::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]); } } } if ($sheet->getTitle() === 'objects') { Object::truncate(); foreach ($sheet as $row) { if (!empty($row->category_id)) { $menu = Object::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]); } } } } }