예제 #1
0
 public function updateAlbum(Request $request)
 {
     $albums = json_decode($request->all()['albums'], true);
     $len = count($albums);
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Album::truncate();
     Photo::truncate();
     Album::reindex();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     foreach ($albums as $a) {
         $album = new Album();
         $album->album_id = $a['id'];
         $album->name = $a['name'];
         $album->created_time = $a['created_time'];
         $album->save();
         $photos = $a['photos']['data'];
         foreach ($photos as $p) {
             $photo = new Photo();
             $photo->album_id = $album->id;
             $photo->photo_id = $p['id'];
             $photo->source = $p['source'];
             $photo->save();
         }
     }
     return '1';
 }
예제 #2
0
 public function destroy($year, $month, $day)
 {
     $date = $this->createDate($year, $month, $day);
     $photo = new Photo($date);
     if ($photo->exists() === false) {
         abort(404);
     }
     $photo->delete();
     return response()->json($photo);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $packages = Package::all();
     foreach ($packages as $package) {
         $filename = sprintf('%s-Tour.jpg', str_replace(' ', '-', $package->name));
         $newPhoto = new Photo();
         $newPhoto->path = $filename;
         $newPhoto->imageable_id = $package->id;
         $newPhoto->imageable_type = 'App\\Package';
         $newPhoto->save();
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $categories = Category::all();
     foreach ($categories as $category) {
         $filename = sprintf('%s-Tour.jpg', str_replace([' ', '/'], '-', $category->name));
         $newPhoto = new Photo();
         $newPhoto->path = $filename;
         $newPhoto->imageable_id = $category->id;
         $newPhoto->imageable_type = 'App\\Category';
         $newPhoto->save();
     }
 }
예제 #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //Here we will ceate a new object of model file called
     $photo = new Photo();
     $photo->name = $request->name;
     //$photo->path = $request->file("photoFile");
     $photo->user_id = $request->user_id;
     //I need to copy the file a give it some valid name
     $photo->path = "Photo" . $photo->user_id . ".png";
     $request->file("photoFile")->move(storage_path() . "/" . $photo->path);
     $photo->save();
     return redirect('/photo');
 }
예제 #6
0
 public function index($format, $year, $month, $day)
 {
     $date = $this->createDate($year, $month, $day);
     $photo = new Photo($date);
     if ($photo->exists() === false) {
         abort(404);
     }
     if (array_key_exists($format, $photo->maxSizes) === false) {
         abort(400);
     }
     $filePath = $photo->getPath($format, true);
     return response()->download($filePath, $photo->getDownloadName());
 }
 public function uploadPhotos(Request $request)
 {
     //adding image during image intervention
     $image = Input::file('image');
     $filename = time() . '-' . $image->getClientOriginalName();
     $path = $image->move('images\\photos', $filename);
     // Image::make($image->getRealPath())->resize('600','400')->save($path);
     $photo = new Photo();
     $photo->photo_name = $filename;
     $photo->album_id = $request->input('album_id');
     $photo->save();
     return redirect('profile');
 }
예제 #8
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $photoDirectory = env('BH_PHOTO_DIRECTORY');
     $fileExtension = $this->file->getClientOriginalExtension();
     $fileName = str_random(10) . '.' . $fileExtension;
     $image = \Image::make($this->file->getRealPath());
     $image->resize(800, 800);
     $image->save($photoDirectory . '/photo_files/normal/' . $fileName);
     $image->resize(100, 100);
     $image->save($photoDirectory . '/photo_files/thumbnail/' . $fileName);
     $photo = new Photo();
     $photo->file_name = $fileName;
     $photo->save();
 }
 public function imageUpload(Request $request)
 {
     $rules = ['image' => 'required|image|mimes:jpeg'];
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect('galerija')->withErrors($validator);
     } else {
         $name1 = str_random(6) . '.jpg';
         $request->file('image')->move('images/web/', $name1);
         $photo = new Photo();
         $photo->name = 'images/web/' . $name1;
         $photo->save();
         return redirect('galerija');
     }
 }
예제 #10
0
 public function addPhoto($zip, $street, Request $request)
 {
     $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,png,bmp']);
     $photo = Photo::fromForm($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
     //return view('flyers.show',compact('flyer'));
 }
예제 #11
0
 /**
  * Store a newly created resource in storage.
  *
  * @param StorePhotoRequest $request
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
  */
 public function store(StorePhotoRequest $request)
 {
     //TODO
     // Find a safe way to getClientOriginalExtension()
     //Construct file and path info
     $file = $request->file('photo');
     $ext = '.' . $file->getClientOriginalExtension();
     $filename = time() . $ext;
     $basePath = '/uploads/img/' . $filename;
     $thumbPath = '/uploads/img/thumb/' . $filename;
     $localPath = public_path() . $basePath;
     $localThumbPath = public_path() . $thumbPath;
     //DB info
     $mimeType = $file->getClientMimeType();
     $slug = Photo::generateUniqueSlug(8);
     //Save the full image and the thumb to the server
     $imageFull = Image::make($file->getRealPath())->save($localPath);
     $imageThumb = Image::make($file->getRealPath())->widen(400)->save($localThumbPath);
     //Create the DB entry
     $imageStore = Photo::create(['path' => $basePath, 'thumb_path' => $thumbPath, 'mime_type' => $mimeType, 'slug' => $slug]);
     if ($request->ajax()) {
         return response()->json($imageStore);
     } else {
         return redirect()->route('home')->with(['global-message' => 'Uploaded!', 'message-type' => 'flash-success']);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param OrganisationRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(OrganisationRequest $request)
 {
     /**
      * If Photo is present then
      */
     if ($request->hasFile('photo')) {
         if ($request->file('photo')->isValid()) {
             $photoName = md5(Carbon::now()) . "." . $request->file('photo')->getClientOriginalExtension();
             $request->file('photo')->move(public_path('images'), $photoName);
             $photo = Photo::create(['url' => $photoName]);
             $photoId = $photo->id;
         } else {
             return back()->withNotification('Error! Photo Invalid!')->withType('danger');
         }
     } else {
         $photoId = null;
     }
     $slug = slug_for_url($request->name);
     $details = empty($request->details) ? null : $request->details;
     $initials = empty($request->initials) ? null : $request->initials;
     $address = empty($request->address) ? null : $request->address;
     if (Auth::check()) {
         $request->user()->organisations()->create(['name' => $request->name, 'initials' => $initials, 'details' => $details, 'address' => $address, 'photo_id' => $photoId, 'slug' => $slug, 'user_ip' => $request->getClientIp()]);
     } else {
         $user = User::findOrFail(1);
         $user->organisations()->create(['name' => $request->name, 'initials' => $initials, 'details' => $details, 'address' => $address, 'photo_id' => $photoId, 'slug' => $slug, 'user_ip' => $request->getClientIp()]);
     }
     return back()->withNotification('Organisation has been added!')->withType('success');
 }
예제 #13
0
 /**
  * A basic test example.
  *
  * @return void
  */
 public function test_a_photo_has_a_path()
 {
     $photo = Photo::create(['path' => '/storage/test.png']);
     $photo = Photo::find(1);
     $path = $photo->path;
     $this->assertequals("/storage/test.png", $path);
 }
 /**
  *
  */
 public function run()
 {
     $faker = Faker::create('en_US');
     /*
      * Base User Accounts
      */
     // Mike's account
     $michael = User::create(['name' => 'Michael Norris', 'email' => '*****@*****.**', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //$michaelProfile = Profile::create([
     //    'user_id'    => $michael->id,
     //    'nick_name'  => 'Mike',
     //    'photo_url'  => 'https://placeholdit.imgix.net/~text?txt=Mike&txtsize=80&bg=eceff1&txtclr=607d8b&w=640&h=640', //'/profile_photos/mike.jpg',
     //    'created_at' => Carbon::now(),
     //    'updated_at' => Carbon::now()
     //]);
     //
     //$michael->profile()->save($michaelProfile);
     unset($photos);
     $photos = [];
     foreach (range(1, 20) as $index) {
         $photos[] = ['id' => Uuid::generate(4), 'path' => $index . '.jpeg'];
         //echo $photos[$index + 1] . "\r\n";
     }
     Photo::insert($photos);
 }
예제 #15
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $attributes = $request->only(array('username', 'first_name', 'last_name', 'description', 'email', 'tel_no', 'type', 'password'));
     // Create user.
     $user = $this->create($attributes);
     if ($request->file('image')) {
         //make timestamp and append username for filename
         $timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
         $imageFile = Input::file('image');
         $mime = "." . substr($imageFile->getMimeType(), 6);
         //move file to /public/images/
         $filename = $timestamp . '-' . $user->username;
         $photoData = array('fileName' => $filename, 'mime' => $mime);
         $photo = Photo::create($photoData);
         $imageFile->move(public_path() . '/images/uploads/', $filename . $mime);
         //associate the image with the user
         $user->photo_id = $photo->id;
         $user->photo()->associate($photo);
     }
     $user->save();
     // Send confirmation link.
     return $this->sendConfirmationLink($user);
 }
예제 #16
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     if ($this->newOnly) {
         $photosQueryBuilder = Photo::where('posted_date', '=', '0000-00-00');
     } else {
         $photosQueryBuilder = Photo::where('id', '>', 0);
     }
     $photos = $photosQueryBuilder->get();
     $gridColumns = [(new FieldConfig('id'))->setLabel('Actions')->setSortable(true)->setCallback(function ($val, EloquentDataRow $row) {
         $rowData = $row->getSrc();
         $iconShow = '<span class="fa fa-eye"></span>&nbsp;';
         $hrefShow = action('PhotosController@show', [$val]);
         $iconUpdate = '<span class="fa fa-pencil"></span>&nbsp;';
         $hrefUpdate = action('PhotosController@edit', [$val]);
         $iconDelete = '<span class="fa fa-times"></span>&nbsp;';
         $hrefDelete = action('PhotosController@delete', [$val]);
         $iconTumblr = '<span class="fa fa-tumblr-square"></span>&nbsp;';
         $hrefTumblr = $rowData->url;
         return '<a href="' . $hrefShow . '">' . $iconShow . '</a>&emsp;' . '<a href="' . $hrefUpdate . '">' . $iconUpdate . '</a>&emsp;' . '<a href="' . $hrefDelete . '">' . $iconDelete . '</a>&emsp;' . '<a href="' . $hrefTumblr . '" target="_blank">' . $iconTumblr . '</a>';
     }), (new FieldConfig('file_name'))->setLabel('Photo')->setCallback(function ($val, EloquentDataRow $row) {
         $rowData = $row->getSrc();
         $image = '<img src="/photo_files/thumbnail/' . $val . '" />';
         $hrefShow = action('PhotosController@show', [$rowData->id]);
         return '<a href="' . $hrefShow . '">' . $image . '</a>';
     }), (new FieldConfig('posted_date'))->setSortable(true)->setSorting(Grid::SORT_DESC), (new FieldConfig('notes'))->setSortable(true), (new FieldConfig('notes_last30'))->setSortable(true)->setLabel('Last 30 Days'), (new FieldConfig('notes_last10'))->setSortable(true)->setLabel('Last 10 Days')];
     $gridCfg = (new GridConfig())->setDataProvider(new EloquentDataProvider($photosQueryBuilder))->setColumns($gridColumns);
     $grid = new Grid($gridCfg);
     return array('narrowGrid' => null, 'grid' => $grid);
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $recordsPerPage = 3;
     $offset = ($this->page - 1) * $recordsPerPage;
     $count = Photo::count();
     if ($this->page > 1) {
         $previousPage = $this->page - 1;
     } else {
         $previousPage = null;
     }
     if ($this->page * $recordsPerPage < $count) {
         $nextPage = $this->page + 1;
     } else {
         $nextPage = null;
     }
     $photos = Photo::orderBy('posted_date', 'desc')->skip($offset)->take($recordsPerPage)->get();
     //$previousUrl = action('PhotosController@index', ['page' => $previousPage]);
     //$nextUrl = action('PhotosController@index', ['page' => $nextPage]);
     if ($previousPage) {
         $previousUrl = url('photos/display/' . $previousPage);
     } else {
         $previousUrl = null;
     }
     if ($nextPage) {
         $nextUrl = url('photos/display/' . $nextPage);
     } else {
         $nextUrl = null;
     }
     return ['photos' => $photos, 'previousUrl' => $previousUrl, 'nextUrl' => $nextUrl];
 }
예제 #18
0
 /**
  * Generates a random string and then checks the database to see if it is unique.
  *
  * @param $number
  * @return string
  */
 public static function generateUniqueSlug($number)
 {
     do {
         $slug = str_random($number);
     } while (!Photo::isSlugUnique($slug));
     //While slug is not unique
     return $slug;
 }
예제 #19
0
 public function index()
 {
     $news = $this->news->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
     $sliders = Photo::join('photo_album', 'photo_album.id', '=', 'photo.photo_album_id')->where('photo.slider', 1)->orderBy('photo.position', 'DESC')->orderBy('photo.created_at', 'DESC')->select('photo.filename', 'photo.name', 'photo.description', 'photo_album.folderid')->get();
     $photoalbums = PhotoAlbum::select(array('photo_album.id', 'photo_album.name', 'photo_album.description', 'photo_album.folderid', DB::raw('(select filename from ' . DB::getTablePrefix() . 'photo WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'photo.photo_album_id=' . DB::getTablePrefix() . 'photo_album.id) AS album_image'), DB::raw('(select filename from ' . DB::getTablePrefix() . 'photo WHERE ' . DB::getTablePrefix() . 'photo.photo_album_id=' . DB::getTablePrefix() . 'photo_album.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $videoalbums = VideoAlbum::select(array('video_album.id', 'video_album.name', 'video_album.description', 'video_album.folderid', DB::raw('(select youtube from ' . DB::getTablePrefix() . 'video as v WHERE album_cover=TRUE and v.video_album_id=' . DB::getTablePrefix() . 'video_album.id) AS album_image'), DB::raw('(select youtube from ' . DB::getTablePrefix() . 'video WHERE ' . DB::getTablePrefix() . 'video.video_album_id=' . DB::getTablePrefix() . 'video_album.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     return view('site.home.index', compact('news', 'sliders', 'videoalbums', 'photoalbums'));
 }
예제 #20
0
 public function delete(Request $request, $id)
 {
     $photo = Photo::findOrFail($id);
     $photo->removeThumbnail();
     unlink($photo->path);
     $albumId = $photo->album_id;
     $photo->delete();
     return redirect('/album/' . $albumId);
 }
 /**
  * Handle the event.
  *
  * @param  UserWasDeleted  $event
  * @return void
  */
 public function handle(UserWasDeleted $event)
 {
     // Delete everything the user created
     Article::where('user_id', $event->user_id)->delete();
     Photo::where('user_id', $event->user_id)->delete();
     PhotoAlbum::where('user_id', $event->user_id)->delete();
     Video::where('user_id', $event->user_id)->delete();
     VideoAlbum::where('user_id', $event->user_id)->delete();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $photo = Photo::find($id);
     $title = $photo->title;
     File::delete('uploads/' . $title);
     File::delete('uploads/thumbs/' . $title);
     $photo->delete();
     return redirect()->back();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \Eloquent::unguard();
     \DB::table('photos')->delete();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 50; $i++) {
         Photo::create(array('project_id' => $faker->numberBetween(1, 50), 'photoUrl' => $faker->imageUrl(150, 150, 'city')));
     }
 }
예제 #24
0
 /**
  * Show the parter list to the user.
  *
  * @return Response
  */
 function getIndex()
 {
     $set = DataSet::source(Photo::with('Object'));
     $set->link(url('/photo/edit'), '', 'show');
     $set->link(url('/photo/edit'), "anlegen", "TR");
     $set->paginate(10);
     $set->build();
     return view('set.photo', compact('set'));
 }
예제 #25
0
 /**
  * Get profile photo of user
  */
 function getOp(Request $request)
 {
     $photo = Photo::find($request->get('id'));
     if ($photo instanceof Photo) {
         return self::respond($photo->path);
     } else {
         throw new \Exception();
     }
 }
예제 #26
0
 /**
  * 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();
     return view('pages.home', compact('articles', 'sliders', 'videoAlbums', 'photoAlbums'));
     //return view('pages.welcome');
 }
 public function index()
 {
     $title = "Dashboard";
     $article = Article::count();
     $articlecategory = ArticleCategory::count();
     $users = User::count();
     $photo = Photo::count();
     $photoalbum = PhotoAlbum::count();
     return view('admin.dashboard.index', compact('title', 'article', 'articlecategory', 'photo', 'photoalbum', 'users'));
 }
예제 #28
0
 public function viewReadOnePublic($id)
 {
     // Set logged in user to a variable.
     $authUser = Auth::user();
     // Find the user in the database.
     $user = User::findOrFail($id);
     $photos = Photo::where('user_id', '=', $user->id)->where('private', '=', 0)->latest('id')->paginate(12);
     // Return view with variables.
     return view('user.viewReadOnePublic')->with('authUser', $authUser)->with('user', $user)->with('photos', $photos);
 }
예제 #29
0
 public function savePhoto(Request $request)
 {
     $user = $request->get('CurrentUser');
     if ($user != null) {
         $photo64 = $request->json()->get('photo');
         $newPhoto = Photo::create(['user_id' => $user->id, 'photo' => $photo64]);
         return Response::json(['result' => 'success', 'photo' => $newPhoto->id], 200);
     } else {
         return Response::json(['result' => 'failed', 'message' => 'not authenticated']);
     }
 }
예제 #30
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($albumId, $id)
 {
     $photo = Photo::findOrFail($id);
     try {
         File::delete(public_path() . '/uploads/photos/' . $photo->photo);
         $photo->destroy($id);
     } catch (Exception $e) {
         App::abort(404);
     }
     return Redirect::route('admin.photos.show', $albumId);
 }