public function grow() { foreach ($this->paintings as $painting) { $p = new Painting(); $p->name = $painting['name']; $p->dimensions = $painting['dimensions']; $p->type = $painting['type']; $p->painter = $painting['painter']; $p->year = $painting['year']; $p->comment = $painting['comment']; $p->image_path = $painting['image_path']; $p->save(); $p->tag($this->getTags()); } }
public function get_index($painter = 'all') { $paintings = null; $painter_name = null; if ($painter == 'all') { $paintings = Painting::with('tags')->order_by('created_at')->paginate(Config::get('app.paginator_count')); $painter_name = __('application.all'); } else { $paintings = Painting::with('tags')->where('painter', 'LIKE', '%' . $painter . '%')->order_by('created_at')->paginate(Config::get('app.paginator_count')); $painter_name = $painter == 'brouwer' ? __('application.brouwer') : __('application.jacas'); } return View::make('work.index')->with('title', HtmlHelpers::name('work') . ' - ' . $painter_name)->with('nav', 'work')->with('painter', $painter_name)->with('paintings', $paintings); }
public static function search_paintings($q) { $cleaner = new Cleaner(); $cleaned_array = $cleaner->parseString($q); $stemmed_array = array_map('PorterStemmer::Stem', $cleaned_array); $paintings = Painting::with('tags')->distinct(); $paintings = $paintings->where(function ($query) use($stemmed_array) { $query->where('name', 'LIKE', '%' . array_get($stemmed_array, 0) . '%'); for ($i = 1; $i < count($stemmed_array); $i++) { $query->or_where('name', 'LIKE', '%' . array_get($stemmed_array, $i) . '%'); } }); $paintings = $paintings->or_where(function ($query) use($stemmed_array) { $query->where('dimensions', 'LIKE', '%' . array_get($stemmed_array, 0) . '%'); for ($i = 1; $i < count($stemmed_array); $i++) { $query->or_where('dimensions', 'LIKE', '%' . array_get($stemmed_array, $i) . '%'); } }); $paintings = $paintings->or_where(function ($query) use($stemmed_array) { $query->where('type', 'LIKE', '%' . array_get($stemmed_array, 0) . '%'); for ($i = 1; $i < count($stemmed_array); $i++) { $query->or_where('type', 'LIKE', '%' . array_get($stemmed_array, $i) . '%'); } }); $paintings = $paintings->or_where(function ($query) use($stemmed_array) { $query->where('painter', 'LIKE', '%' . array_get($stemmed_array, 0) . '%'); for ($i = 1; $i < count($stemmed_array); $i++) { $query->or_where('painter', 'LIKE', '%' . array_get($stemmed_array, $i) . '%'); } }); $paintings = $paintings->or_where(function ($query) use($stemmed_array) { $query->where('year', 'LIKE', '%' . array_get($stemmed_array, 0) . '%'); for ($i = 1; $i < count($stemmed_array); $i++) { $query->or_where('year', 'LIKE', '%' . array_get($stemmed_array, $i) . '%'); } }); $paintings = $paintings->or_where(function ($query) use($stemmed_array) { $query->where('comment', 'LIKE', '%' . array_get($stemmed_array, 0) . '%'); for ($i = 1; $i < count($stemmed_array); $i++) { $query->or_where('comment', 'LIKE', '%' . array_get($stemmed_array, $i) . '%'); } }); $paintings = $paintings->order_by('created_at', 'DESC'); $paintings = $paintings->paginate(Config::get('app.paginator_count')); return array(implode(' ', $cleaned_array), $paintings); }
return View::make('hello', array('theLocation' => 'NYC', 'theWeather' => 'stormy', 'theLandmarks' => $theLandmarks)); }); Route::get('insert', function () { $painting = new Painting(); $painting->title = 'Do No Wrong'; $painting->artist = "D. DoRight"; $painting->year = 2014; $painting->save(); return 'Record Inserted Succefully.'; }); Route::get('find', function () { $painting = Painting::find(2); return $painting->title; }); Route::get('change', function () { $painting = Painting::find(2); $painting->title = 'Be Successful'; $painting->save(); return 'Title changed to ' . $painting->title; }); Route::get('about', function () { return 'This is the About Page.'; }); Route::get('about/directions', function () { return 'This is the Directions Page.'; }); Route::get('about/{theSubject}', function ($theSubject) { return $theSubject . ' content goes here.'; }); Route::get('about/classes/{theSubject}', function ($theSubject) { return "Content about {$theSubject} goes here.";
<?php Route::get('test', function () { $painting = Painting::first(); $tags = $painting->tags; dd($tags); }); // Language Route::get('language/(:any)', array('as' => 'language.set', 'uses' => 'language@set')); // Feed Route::get('feed', array('as' => 'feed.index', 'uses' => 'feed@index')); // Home Route::get('/', array('as' => 'home.index', 'uses' => 'home@index')); Route::get('about', array('as' => 'home.about', 'uses' => 'home@about')); Route::get('faq', array('as' => 'home.faq', 'uses' => 'home@faq')); Route::get('contact', array('as' => 'home.contact', 'uses' => 'home@contact')); Route::post('about/send', array('as' => 'home.about.send', 'uses' => 'home@send_message')); // Work Route::get('work/(:any?)', array('as' => 'work.index', 'uses' => 'work@index')); Route::get('work/paintings/search', array('as' => 'work.search', 'uses' => 'work@paintings_search')); // Events Route::get('events', array('as' => 'events.index', 'uses' => 'events@index')); // Tags Route::get('tags', array('as' => 'tags.index', 'uses' => 'tags@index')); Route::get('tags/(:any)', array('as' => 'tags.show', 'uses' => 'tags@show')); // Session Route::get('session/login', array('as' => 'session.login', 'uses' => 'session@login')); Route::post('session/login', array('as' => 'session.login.check', 'uses' => 'session@login')); Route::get('session/logout', array('as' => 'session.logout', 'uses' => 'session@logout')); Route::get('session/reset', array('as' => 'session.reset', 'uses' => 'session@reset')); Route::post('session/reset', array('as' => 'session.reset.check', 'uses' => 'session@reset'));
public function delete_paintings_delete($painting_id) { $painting = Painting::find($painting_id); $errors = new Laravel\Messages(); if ($painting) { if ($painting->delete_painting()) { return Redirect::to(URL::to_route('dashboard.paintings'))->with('status_success', __('application.painting_deleted')); // } // if ($painting->delete()) { // $directory = path('public').'uploads/paintings/'.sha1($name); // File::rmdir($directory); // return Redirect::to(URL::to_route('dashboard.paintings')) // ->with('status_success', __('application.painting_deleted')); } else { $errors->add('errors', __('application.generic_error')); return Redirect::to(URL::to_route('dashboard.paintings'))->with_errors($errors); } } else { return Response::error(404); } }
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::get('/', function () { $painting = Painting::find(1); $painting->title = 'Do No Wrong - Just Do Right'; $painting->save(); return $painting->title; /* $painting = new Painting; $painting->title = 'Do No Wrong'; $painting->artist = 'D. DoRight'; $painting->date = 2014; $painting->save(); return View::make('hello'); */ }); Route::get('about', function () { return 'About content goes here'; }); Route::get('about/directions', function () {