Пример #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     for ($i = 68; $i <= 78; $i++) {
         //$photos=Image::paginate(50);
         $client = new Client();
         $baseURL = 'http://www.cutecatgifs.com/page';
         $urlEndpoint = '/' . $i++;
         $crawler = $client->request('GET', $baseURL . $urlEndpoint);
         $photos = $crawler->filter('img.alignnone')->extract(array('src', 'alt'));
         foreach ($photos as $photo) {
             $url = $photo[0];
             $title = $photo[1];
             $extension = pathinfo($url, PATHINFO_EXTENSION);
             $filename = str_random(4) . '-' . str_slug($title) . '.' . $extension;
             // get file content from url and save in directory
             $file = file_get_contents($url);
             $save_file = file_put_contents('uploads/' . $filename, $file);
             // Create record in database
             $image = new \App\Image();
             $image->name = $photo[1];
             $image->url = $filename;
             $image->user_id = 1;
             $image->description = $photo[1];
             $image->save();
         }
     }
 }
Пример #2
0
 function getExample2()
 {
     $image = new \App\Image();
     $image->filename = '565.jpg';
     $image->date_taken = '1911-11-11';
     $image->narrative = "why did I take this?";
     $image->save();
     dump($image);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 1; $i <= 320; $i++) {
         $image = new \App\Image();
         $image->title = "Title {$i}";
         $image->caption = "Caption photo {$i}";
         $image->vote_count = 0;
         $image->url_path = "1 ({$i}).jpg";
         $image->save();
     }
 }
Пример #4
0
 public function saving($model)
 {
     $tmp_model = new \App\Image();
     // RULES
     if (is_array($model->image_ids)) {
         foreach ($model->image_ids as $k => $v) {
             $rules['image_ids' . $k] = ['exists:' . $tmp_model->getTable()];
         }
     } else {
         $rules['image_ids'] = ['exists:' . $tmp_model->getTable()];
     }
     $validator = Validator::make($model->toArray(), $rules);
     if ($validator->fails()) {
         $model->setErrors($validator->messages());
         return false;
     }
 }
Пример #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     error_log($request);
     $this->validate($request, ['file' => 'image']);
     // save file to disk
     $saved_path = '/app/uploads';
     $saved_name = $request->file->getBasename() . '.' . $request->file->getClientOriginalExtension();
     $request->file->move($saved_path, $saved_name);
     $image = new \App\Image();
     $image->path = $saved_path . '/' . $saved_name;
     $image->uniqid = $request->uniqid;
     // save info in database
     if ($image->save()) {
         return response()->json(['images' => [$image]], 201);
     } else {
         return response()->json(['success' => false], 401);
     }
 }
Пример #6
0
 public function run()
 {
     // clear our database ------------------------------------------
     DB::table('users')->delete();
     DB::table('persons')->delete();
     DB::table('images')->delete();
     // Seed the Persons Table
     // Father
     $daveLove = App\Person::create(array('first_name' => 'Dave', 'last_name' => 'Love', 'father_id' => NULL, 'mother_id' => NULL, 'dob' => '1952-01-07', 'dod' => '1999-04-07', 'description' => 'Dave Love was an independent mechanic with 3 children', 'gender' => 'M', 'marriage_id' => NULL));
     // Mother
     $leenaLove = App\Person::create(array('first_name' => 'Leena', 'last_name' => 'Love', 'father_id' => NULL, 'mother_id' => NULL, 'dob' => '1955-02-05', 'dod' => NULL, 'description' => 'Leena Love is was a house wife and is now currently studying fashion design.', 'gender' => 'F', 'marriage_id' => NULL));
     // Son 1
     $tysonLove = App\Person::create(array('first_name' => 'Tyson', 'last_name' => 'Love', 'father_id' => $daveLove->id, 'mother_id' => $leenaLove->id, 'dob' => '1980-02-01', 'dod' => NULL, 'description' => 'Tyson love is the eldest child in his family. Currently teaching at college', 'gender' => 'M', 'marriage_id' => NULL));
     // Son 2
     $fosterLove = App\Person::create(array('first_name' => 'Foster', 'last_name' => 'Love', 'father_id' => $daveLove->id, 'mother_id' => $leenaLove->id, 'dob' => '1988-07-09', 'dod' => NULL, 'description' => 'Foster is the second eldest child in his family. Doing an apprentership.', 'gender' => 'M', 'marriage_id' => NULL));
     // Daughter 1
     $jeanLove = App\Person::create(array('first_name' => 'Jean', 'last_name' => 'Love', 'father_id' => $daveLove->id, 'mother_id' => $leenaLove->id, 'dob' => '1996-06-06', 'dod' => NULL, 'description' => 'Jean is the youngest child in her family. She recently started high school..', 'gender' => 'F', 'marriage_id' => NULL));
     $this->command->info('People have been generated in the database!');
     // Set marriage relationships
     $daveLove->marriage_id = $daveLove->gender . $daveLove->id . $leenaLove->gender . $leenaLove->id;
     $leenaLove->marriage_id = $daveLove->gender . $daveLove->id . $leenaLove->gender . $leenaLove->id;
     $this->command->info('Relationship links have been created!');
     // Create Image Gallery
     $images_daveLove = App\Image::create(array('url' => 'http://www.alifazel.com/sample_images/faces/dad_full.jpg', 'url_thumb' => 'http://www.alifazel.com/sample_images/faces/dad_thumb.jpg', 'description' => 'Profile Picture of Dave Love', 'date_taken' => '1998-02-10'));
     $images_leenaLove = App\Image::create(array('url' => 'http://www.alifazel.com/sample_images/faces/mum_full.jpg', 'url_thumb' => 'http://www.alifazel.com/sample_images/faces/mum_thumb.jpg', 'description' => 'Profile Picture of Leena Love', 'date_taken' => '2002-02-10'));
     $images_tysonLove = App\Image::create(array('url' => 'http://www.alifazel.com/sample_images/faces/son1_full.jpg', 'url_thumb' => 'http://www.alifazel.com/sample_images/faces/son1_thumb.jpg', 'description' => 'Profile Picture of Tyson Love', 'date_taken' => '2002-02-10'));
     $images_fosterLove = App\Image::create(array('url' => 'http://www.alifazel.com/sample_images/faces/son2_full.jpg', 'url_thumb' => 'http://www.alifazel.com/sample_images/faces/son2_thumb.jpg', 'description' => 'Profile Picture of Foster Love', 'date_taken' => '2002-02-10'));
     $images_jeanLove = App\Image::create(array('url' => 'http://www.alifazel.com/sample_images/faces/daughter_full.jpg', 'url_thumb' => 'http://www.alifazel.com/sample_images/faces/daughter_thumb.jpg', 'description' => 'Profile Picture of Jean Love', 'date_taken' => '2002-02-10'));
     // Create image relation
     $daveLove->images()->attach($images_daveLove->id);
     $leenaLove->images()->attach($images_leenaLove->id);
     $tysonLove->images()->attach($images_tysonLove->id);
     $fosterLove->images()->attach($images_fosterLove->id);
     $jeanLove->images()->attach($images_jeanLove->id);
     $this->command->info('Image gallery has been created!');
     $daveLove->profile_picture_id = $images_daveLove->id;
     $leenaLove->profile_picture_id = $images_leenaLove->id;
     $tysonLove->profile_picture_id = $images_tysonLove->id;
     $fosterLove->profile_picture_id = $images_fosterLove->id;
     $jeanLove->profile_picture_id = $images_jeanLove->id;
     $daveLove->save();
     $leenaLove->save();
     $tysonLove->save();
     $fosterLove->save();
     $jeanLove->save();
     $this->command->info('Profile Pictures have been set!');
     // Create User Account
     App\User::create(array('email' => '*****@*****.**', 'username' => 'leena', 'password' => bcrypt('love'), 'person_id' => $leenaLove->id));
     $this->command->info('User account has been created');
     // WIP - Fill in the rest of the people. Create a Hierachy and use that to generate. Create a gallery also (1P 1Img, 2P 1Img)
 }
Пример #7
0
  * ===========================================================
  * Contacts
  */
 Route::get('contacts/search', ['as' => 'admin.contacts.search', 'uses' => 'ContactsController@search']);
 Route::post('contacts/image/{id}', ['as' => 'admin.contacts.image', 'uses' => 'ContactsController@postImage']);
 Route::bind('contacts', function ($id) {
     return App\Contact::findOrFail($id);
 });
 Route::resource('contacts', 'ContactsController', []);
 /**
  * ========================================================
  * Images
  */
 Route::get('images/search', ['as' => 'images.search', 'uses' => 'ImagesController@search']);
 Route::bind('images', function ($id) {
     return App\Image::with('products')->findOrFail($id);
 });
 Route::resource('images', 'ImagesController');
 /**
  * ========================================================
  * Products
  */
 Route::get('products/search', ['as' => 'admin.products.search', 'uses' => 'ProductsController@search']);
 Route::get('products/{slug}/images', ['as' => 'admin.products.edit_images', 'uses' => 'ProductsController@editImages']);
 Route::post('products/{slug}/images', ['as' => 'admin.products.update_images', 'uses' => 'ProductsController@updateImages']);
 Route::bind('products', function ($slug) {
     return App\Product::whereSlug($slug)->with('images')->firstOrFail();
 });
 Route::resource('products', 'ProductsController');
 /**
  * ===========================================================
Пример #8
0
<?php

Auth::routes();
Route::get('/', function () {
    return view('index')->with('minifigs', App\Minifig::count())->with('sets', App\Set::count())->with('images', App\Image::count())->with('latest_minifig', App\Minifig::latest())->with('latest_set', App\Set::latest());
});
Route::resource('minifigs', 'MinifigController');
Route::resource('sets', 'SetController');
Route::resource('images', 'ImageController', ['only' => ['destroy']]);