Exemplo n.º 1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     if (Auth::check()) {
         $collections = Collection::all();
         return view('admin.items.create', ['collections' => $collections]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Collection::create(['name' => 'Rocky I Series', 'description' => 'Allow natural light in while enjoying moderate privacy. These styles are sleek, beautiful and perfect for any decor. A good solution for reducing glare. Choose from over 50 materials.', 'image_path' => '/img/collections/light-filtering.jpg', 'treatment_id' => 1]);
     Collection::create(['name' => 'Rocky II Series', 'description' => 'Light interfering with your sleep? Here\'s an affordable solution - 37 beautiful blackout materials, perfect for blocking natural light from filling your room.', 'image_path' => '/img/collections/blackout.jpg', 'treatment_id' => 1]);
     Collection::create(['name' => 'Rocky III Series', 'description' => 'Our sleek, modern rollers paired with our exclusive naturals collection. Choose from 49 eco-friendly looks sourced from low-impact materials.', 'image_path' => '/img/collections/naturals.jpg', 'treatment_id' => 1]);
     Collection::create(['name' => 'Galaxy Series', 'description' => 'Protect your home from sun damage and harmful UV rays while preserving your view. Choose from 4 levels of transparency each available in 9 colors.', 'image_path' => '/img/collections/basic.jpg', 'treatment_id' => 2]);
     Collection::create(['name' => 'Losa Series', 'description' => 'A stylish way to ward off sun damage. All the benefits of our basics but with a touch of flair. Over 25 beautiful looks spanning 7 exclusive collections.', 'image_path' => '/img/collections/designer.jpg', 'treatment_id' => 2]);
     Collection::create(['name' => 'Sara Series', 'description' => 'Chilewich has put together an exclusive collection of 21 beautiful weaves for our solar shades. Add a modern, sophisticated accent to any interior. ', 'image_path' => '/img/collections/chilewich.jpg', 'treatment_id' => 2]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     $users = User::lists('id')->all();
     $collections = Collection::lists('id')->all();
     $limit = 10;
     for ($i = 0; $i < $limit; $i++) {
         DB::table('like')->insert(['user_id' => $faker->randomElement($users), 'collection_id' => $faker->randomElement($collections)]);
     }
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     $this->app['validator']->extend('checkSecret', function ($attribute, $value, $parameters) {
         $c = \App\Collection::where('secret', $value)->first();
         if ($c) {
             return true;
         }
         return false;
     });
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     $movies = Movie::lists('id')->all();
     $collections = Collection::lists('id')->all();
     $limit = 20;
     for ($i = 0; $i < $limit; $i++) {
         DB::table('collection_movie')->insert(['collection_id' => $faker->randomElement($collections), 'movie_id' => $faker->randomElement($movies)]);
     }
 }
 public static function search($query)
 {
     if (empty($query)) {
         return Collection::make();
     }
     return Department::where('name', 'like', '%' . $query . '%')->orderBy('name', 'asc')->take(5)->get(array('id', 'name'))->map(function ($department) {
         $department->label = $department->name;
         $department->type = 'department';
         $department->url = route('departments.show', $department->id);
         return $department;
     });
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $cid = $request->route('cid');
     if (\Session::has('rightToEdit')) {
         try {
             $collection = \App\Collection::findOrFail($cid);
         } catch (ModelNotFoundException $e) {
             \Session::flash('errorMsg', 'Collection not found!');
             return \Redirect::route('askcollectionkey');
         }
         if (\Session::get('rightToEdit') !== $collection->id . "_" . $collection->secret) {
             \Session::flash('errorMsg', 'Provide collection password in order to edit it!');
             return \Redirect::route('askcollectionkey');
         }
         return $next($request);
     } else {
         \Session::flash('errorMsg', 'You have not provided collection password.');
         return \Redirect::route('askcollectionkey');
     }
 }
 private function addTournamentToDB($nimi, $aika, $secret, $pistelasku, $ratkaisuaika)
 {
     try {
         $collection = \App\Collection::where('secret', $secret)->firstOrFail();
     } catch (ModelNotFoundException $e) {
         \Session::flash('errorMsg', 'Secret key not found!');
         return \Redirect::back();
     }
     $tournament = new \App\Tournament();
     $key = $this->createNewSecret();
     $tournament->key = $key;
     $tournament->name = $nimi;
     $tournament->starts_at = date('Y-m-d H:i:s', strtotime($aika));
     $tournament->pistelasku = $pistelasku;
     $tournament->ratkaisuaika = $ratkaisuaika;
     $tournament->loaded_to_server = 0;
     $tournament->collection_id = $collection->id;
     $tournament->save();
     return $key;
 }
Exemplo n.º 9
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getBooks(Request $request)
 {
     try {
         $term = $request->input();
         $url = '';
         if (count($term) > 1) {
             $books = Book::where('books.active', 1);
             if ($term['title'] != '') {
                 $books = $books->where('title', 'like', '%' . $request->input('title') . '%');
             }
             $url['title'] = $term['title'];
             if ($term['author'] != '') {
                 $books = $books->join('author_book', 'books.id', '=', 'author_book.book_id');
                 $books = $books->join('authors', 'author_book.author_id', '=', 'authors.id');
                 $books = $books->where('authors.name', 'like', '%' . $request->input('author') . '%');
             }
             $url['author'] = $term['author'];
             if ($term['collection'] != '') {
                 $books = $books->join('books_collections', 'books_collections.book_id', '=', 'books.id');
                 $books = $books->where('books_collections.collection_id', '=', $request->input('collection'));
             }
             $url['collection'] = $term['collection'];
             if ($term['sort'] != '') {
                 $books = $books->orderBy('price_day', $term['sort']);
             }
             $url['sort'] = $term['sort'];
             $books = $books->select('books.*');
             $books = $books->paginate(6);
         } else {
             $books = \App\Book::where('active', '1')->paginate(6);
         }
     } catch (\Exception $e) {
         return back();
     } finally {
         $collections = ['' => ''] + \App\Collection::lists('collection', 'id')->all();
         return view('home', ['books' => $books, 'collections' => $collections, 'url' => $url]);
     }
 }
Exemplo n.º 10
0
 /**
  * Toggle tattoo collect
  *
  * @return View
  */
 public function collect(Request $request)
 {
     $res = array();
     $res['success'] = false;
     $tattooId = $request->input('id');
     $user = Auth::user();
     if ($user->collections()->where('tattoo_id', $tattooId)->count()) {
         $collection = Collection::where('tattoo_id', $tattooId)->where('user_id', $user->id)->first();
         if ($collection) {
             //already collected so uncollect now(delete)
             $collection->delete();
             $res['data'] = 'Collect';
             //uncollect success now show Collect
             $res['success'] = true;
             $res['collectCount'] = Collection::where('tattoo_id', $tattooId)->count();
         }
     } else {
         $collection = new Collection();
         $collection->tattoo_id = $tattooId;
         $collection->user_id = $user->id;
         if ($collection->save()) {
             $res['data'] = 'Uncollect';
             //collect success now show Uncollect
             $res['success'] = true;
             $res['collectCount'] = Collection::where('tattoo_id', $tattooId)->count();
         }
     }
     return $res;
 }
Exemplo n.º 11
0
 public function search($name)
 {
     $collection = Collection::where('name', 'LIKE', '%' . $name . '%')->get();
     return response()->json(['collections' => $collection]);
 }
Exemplo n.º 12
0
 protected function collectionStore(Request $request, $id = null)
 {
     if (Auth::check()) {
         if ($id) {
             $collection = Collection::find($id);
         } else {
             $collection = new Collection();
         }
         $collection->name = $request->input('collection_name');
         $collection->slug = str_slug($request->input('collection_name'), "-");
         try {
             $collection->save();
             return redirect('/home/collections');
         } catch (\Illuminate\Database\QueryException $e) {
             return $e->getMessage();
         }
     } else {
         return 'No auth';
     }
 }
Exemplo n.º 13
0
 public function index(Collection $collection)
 {
     return view('collections.list', ['objects' => $collection->getAll()]);
 }
 private function createNewSecret($times = 0)
 {
     if ($times > 5) {
         return \App::abort(403, 'Could not create secret key - contact administrator');
     }
     $chars = "qwertyuipasdfghjklzxcvbnm12345678900";
     $secret = "";
     for ($i = 0; $i < 5; $i++) {
         $r = rand(0, strlen($chars) - 1);
         $secret .= $chars[$r];
     }
     if (\App\Collection::where('secret', $secret)->first()) {
         return $this->createNewSecret($times + 1);
     }
     return $secret;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $collections = Collection::all();
     return view('admin.collections.index', ['collections' => $collections]);
 }
Exemplo n.º 16
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $note = Note::find($id);
     $rules = ['title' => 'required|min:2', 'body_text' => 'required|min:5|max:10000', 'is_public' => 'required'];
     if (Auth::User()->id != $note->user_id) {
         Flash::warning('You are not authorized to do that');
         return redirect()->route('home');
     }
     $validator = \Validator::make(Input::only('title', 'body_text', 'is_public'), $rules);
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator);
     }
     $note->title = Input::get('title');
     $note->body_text = Input::get('body_text');
     $note->is_public = Input::get('is_public');
     $note->collection_id = null;
     if (Input::get('collection') > 0) {
         $collection = Collection::find(Input::get('collection'));
         $collection->notes()->save($note);
     }
     $note->save();
     Flash::info('Note Updated!');
     return redirect()->route('notes.show', $note->id);
 }
Exemplo n.º 17
0
 public function addbooks()
 {
     header('Content-Type: text/html; charset=utf-8');
     for ($i = 0; $i <= 10; $i++) {
         $user = new User();
         $user->name = $this->generateRandomString(5);
         $user->password = bcrypt($user->name);
         $user->email = $user->name . '@gmail.com';
         $user->save();
     }
     $names = ['%22feliz%20gouveia%22', '%22nuno%20ribeiro%22', '%22jose%20torres%22', '%22borges%20gouveia%22', '%22Sophia%20breyner%22', '%22Fernando%20Pessoa%22', '%22Eça%20De%20Queiros%22'];
     foreach ($names as $name) {
         $content = file_get_contents('https://www.googleapis.com/books/v1/volumes?q=' . $name);
         $content = json_decode($content, true);
         $auts = Author::all('name');
         $authors = array();
         foreach ($auts as $aut) {
             $authors[] = $aut['name'];
         }
         $pubs = Publisher::all('publisher');
         $publishers = array();
         foreach ($pubs as $pub) {
             $publishers[] = $pub['publisher'];
         }
         $cats = Collection::all('collection');
         $categories = array();
         foreach ($cats as $cat) {
             $categories[] = $cat['collection'];
         }
         foreach ($content['items'] as $data) {
             $data = $data['volumeInfo'];
             $book = new Book();
             if (isset($data['title'])) {
                 $book->title = $data['title'];
             }
             if (isset($data['subtitle'])) {
                 $book->subtitle = $data['subtitle'];
             }
             if (isset($data['publishedDate'])) {
                 $book->publishedDate = $data['publishedDate'];
             }
             if (isset($data['description'])) {
                 $book->description = $data['description'];
             }
             if (isset($data['pageCount'])) {
                 $book->pages = $data['pageCount'];
             }
             if (isset($data['language'])) {
                 $book->language = $data['language'];
             }
             if (isset($data['industryIdentifiers'])) {
                 foreach ($data['industryIdentifiers'] as $value) {
                     if ($value['type'] == 'ISBN_13') {
                         $book->isbn13 = $value['identifier'];
                     }
                     if ($value['type'] == 'ISBN_10') {
                         $book->isbn10 = $value['identifier'];
                     }
                 }
             }
             if (isset($data['publisher'])) {
                 if (!in_array($data['publisher'], $publishers)) {
                     $publishers[] = $data['publisher'];
                     $publisher = new Publisher();
                     $publisher->publisher = $data['publisher'];
                     $publisher->save();
                     $publisher_id = $publisher->id;
                 } else {
                     $publisher = Publisher::where('publisher', '=', $data['publisher'])->limit(1)->get();
                     $publisher_id = $publisher[0]->id;
                 }
             }
             if (isset($data['imageLinks']['thumbnail'])) {
                 $book->cover = file_get_contents($data['imageLinks']['thumbnail']);
             }
             $book->price_day = random_int(0, 15);
             $book->price_bail = random_int(10, 50);
             $book->price_sale = random_int(10, 79);
             $books[] = $book;
             $book->id_publisher = $publisher_id;
             $book->id_user = rand(1, 10);
             $book->save();
             $book_id = $book->id;
             if (isset($data['categories'])) {
                 foreach ($data['categories'] as $value) {
                     if (!in_array($value, $categories)) {
                         $categories[] = $value;
                         $category = new Collection();
                         $category->collection = $value;
                         $category->save();
                         $category_id = $category->id;
                         $collections = new Book_Collection();
                         $collections->book_id = $book_id;
                         $collections->collection_id = $category_id;
                         $collections->save();
                     } else {
                         $category = Collection::where('collection', '=', $value)->limit(1)->get();
                         $collections = new Book_Collection();
                         $collections->book_id = $book_id;
                         $collections->collection_id = $category[0]->id;
                         $collections->save();
                     }
                 }
             }
             if (isset($data['authors'])) {
                 foreach ($data['authors'] as $value) {
                     if (!in_array($value, $authors)) {
                         $authors[] = $value;
                         $author = new Author();
                         $author->name = $value;
                         $author->save();
                         $author_id = $author->id;
                         $author_book = new Author_Book();
                         $author_book->book_id = $book_id;
                         $author_book->author_id = $author_id;
                         $author_book->save();
                     } else {
                         $author = Author::where('name', 'like', $value)->limit(1)->get();
                         $author_book = new Author_Book();
                         $author_book->book_id = $book_id;
                         $author_book->author_id = $author[0]->id;
                         $author_book->save();
                     }
                 }
             }
             # code...
         }
     }
 }
Exemplo n.º 18
0
 public function search($name)
 {
     $products = Product::where('name', 'LIKE', '%' . $name . '%')->get();
     //  $products = Product::add_created_by_and_category($products);
     $collection = Collection::where('name', 'LIKE', '%' . $name . '%')->get();
     // return response()->json(['collections' => $collection]);
     return response()->json(['products' => $products, 'collections' => $collection]);
 }
Exemplo n.º 19
0
| and give it the controller to call when that URI is requested.
|
*/
Route::get('search/getAuthors', 'SearchController@getAuthors');
Route::get('/', 'SearchController@getBooks')->name('home');
//HOME
Route::get('/book/create', ['middleware' => 'auth.role:1', function () {
    $publishers = ['' => ''] + \App\Publisher::lists('publisher', 'id')->all();
    $collections = ['' => ''] + \App\Collection::lists('collection', 'id')->all();
    $publishers[0] = 'Outros';
    return view('book/create', ['publishers' => $publishers, 'collections' => $collections]);
}]);
Route::get('/book/edit/{id}', ['middleware' => 'auth.role:1', function ($id) {
    $book = \App\Book::find($id);
    $publishers = ['' => ''] + \App\Publisher::lists('publisher', 'id')->all();
    $collections = ['' => ''] + \App\Collection::lists('collection', 'id')->all();
    $publishers[0] = 'Outros';
    return view('book/edit', ['book' => $book, 'publishers' => $publishers, 'collections' => $collections]);
}]);
Route::get('/book/list', ['middleware' => 'auth.role:1', function () {
    $books = App\Book::where('id_user', '=', Auth::user()->id)->where('active', 1)->get();
    return view('book/list', ['books' => $books]);
}]);
Route::get('/book/return/{id}', ['middleware' => 'auth.role:1', function ($id) {
    $returns = new App\Returns();
    $returns->rental_id = $id;
    $returns->save();
    return back();
}]);
Route::get('/book/returnConfirmed/{id}', ['middleware' => 'auth.role:1', function ($id) {
    $returns = App\Returns::where('rental_id', $id)->get();
Exemplo n.º 20
0
 public function viewUnapprovedProduct($id)
 {
     $user = Auth::user();
     if ($user != null && $user->hasRole('admin')) {
         $coll = Collection::find($id);
         $collection = CollectionProduct::where('collection_id', '=', $id)->get();
         //  dd($collection) ;
         $collection_list = [];
         $creator = $coll->created_by;
         $creator = User::find($creator);
         foreach ($collection as $pro) {
             $product_id = $pro->product_id;
             $product = Product::find($product_id);
             $product = Product::add_created_by_and_category($product);
             if ($product != null) {
                 $created_by = $product['created_by'];
                 $category = Category::find($product['category_id']);
                 $category = $category['category'];
                 $user = User::find($created_by);
                 array_add($collection, 'category', $category);
                 array_add($collection, 'created_by_name', $user['name']);
                 array_push($collection_list, $product);
             }
         }
         return view('admin.viewUnapprovedCollection')->with('products', $collection_list)->with('collection', $coll);
     } else {
         return view('admin.login');
     }
 }