/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { //$member = Member::find($id); $profileUser = User::where('slug', $id)->first(); $member = Member::where('user_id', $profileUser->id)->first(); $user = Auth::user(); $isMemberProfile = false; $isFollowing = false; $showWelcomeMessage = false; if (Auth::check()) { if ($member->user_id == Auth::User()->id) { $isMemberProfile = true; if (!$user->welcomed) { $showWelcomeMessage = true; $user->welcomed = true; $user->save(); } } if (Follower::where('user_id', $member->user->id)->where('follower_id', $user->id)->count()) { $isFollowing = true; } } $artists = Artist::where('verified', true)->orderBy('firstname', 'asc')->get(); $categories = Tag::where('isCategory', true)->get(); return view('pages.member', ['member' => $member, 'isMemberProfile' => $isMemberProfile, 'isFollowing' => $isFollowing, 'artists' => $artists, 'categories' => $categories, 'showWelcomeMessage' => $showWelcomeMessage]); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { if (Gate::denies('admin')) { abort(403); } $out = ['form_route' => ['route' => 'image.store', 'method' => 'POST', 'class' => 'form-horizontal', 'files' => true]]; if (count(Request::old())) { $rq = Request::old(); $out['image'] = new Image($rq); if (isset($rq['artist_id']) && is_array($rq['artist_id'])) { $out['image']->artists = Artist::whereIn('id', $rq['artist_id'])->get(); } if (isset($rq['release_id']) && is_array($rq['release_id'])) { $out['image']->releases = Release::whereIn('id', $rq['release_id'])->get(); } if (isset($rq['track_id']) && is_array($rq['track_id'])) { $out['image']->tracks = Track::whereIn('id', $rq['track_id'])->get(); } } else { $rq = Request::all(['artist_id', 'release_id', 'track_id']); $out['image'] = new Image(); if (isset($rq['artist_id']) && (int) $rq['artist_id'] > 0) { $out['image']->artists = Artist::where('id', (int) $rq['artist_id'])->get(); } if (isset($rq['release_id']) && (int) $rq['release_id'] > 0) { $out['image']->releases = Release::where('id', (int) $rq['release_id'])->get(); } if (isset($rq['track_id']) && (int) $rq['track_id'] > 0) { $out['image']->tracks = Track::where('id', (int) $rq['track_id'])->get(); } } return view('images.form', $out); }
public function getDataArtist(DestroyArtistRequest $request) { $id = Input::get('id'); $result = []; $model = new Artist(); $data = $model->where('id', $id)->first()->toArray(); foreach ($data as $k => $aData) { $result[$k] = $aData; } $nameFileAvatar = $result['avatar']; $result['avatar'] = $nameFileAvatar; return json_encode($result); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $this->validate($request, ['title' => 'required|unique:auctions|max:255', 'artist' => 'required|max:255', 'year' => 'required|integer|digits_between:3,4|max:2016', 'width' => 'required|numeric', 'height' => 'required|numeric', 'depth' => 'numeric', 'description' => 'required|max:255', 'condition' => 'required|max:255', 'origin' => 'required|max:255', 'picture' => 'required', 'minprice' => 'required|numeric|', 'buyout' => 'required|numeric|greater_than_field:minprice', 'date' => 'required|date|after:today', 'terms' => 'required|accepted']); $artist = Artist::where('name', $request->artist)->first(); if (!$artist) { $artist = new Artist(['name' => $request->artist]); } $artist->save(); $auction = new Auction(['title' => $request->title, 'description' => $request->description, 'start' => Carbon::now(), 'end' => $request->date, 'buy_now' => $request->buyout, 'price' => $request->minprice, 'status' => 'Active', 'style_id' => Style::Where('name', $request->style)->first()->id]); $artwork = new Artwork(['name' => $request->title, 'width' => $request->width, 'height' => $request->height, 'depth' => $request->depth, 'condition' => $request->condition, 'origin' => $request->origin, 'year' => $request->year]); $auction->save(); $artwork->auction()->associate($auction); $artwork->save(); // Picture save $imageName = $artwork->id . '.' . $request->file('picture')->getClientOriginalExtension(); $artwork->image = $imageName; $request->file('picture')->move(base_path() . '/public/img/', $imageName); $artist->artworks()->save($artwork); $owner = $request->user(); $owner->auctionsowner()->save($auction); return redirect('/auctions/' . $owner->id); }
/** * Display the artist's followers * * @return View */ public function edit() { $user = Auth::user(); if (!$user->social) { $user->avatar = url('uploads/images/small/' . $user->avatar); } //if user is artist, load artist profile view if ($user->type == 'artist') { $artist = Artist::where('user_id', $user->id)->first(); $studios = Studio::all(); $artist->cover = url('uploads/images/small/' . $artist->cover); return view('pages.profile.artist.edit', ['user' => $user, 'artist' => $artist, 'studios' => $studios]); } //member can't have followers. so redirect to profile return view('pages.profile.member.edit', ['user' => $user]); }
/** * Approve Tattoo * * @return View */ public function rejectTattoo($id) { $user = Auth::user(); $artist = Artist::where('user_id', $user->id)->first(); $tattoo = Tattoo::find($id); if ($tattoo) { if ($tattoo->artist_id == $artist->id) { $tattoo->delete(); return redirect('artist/' . $artist->id)->with('success', 'Tattoo Deleted Successfully'); } } return redirect('artist/' . $artist->id); }
/** * Update artist Cover * * @return View */ public function updateCover(Request $request) { $user = Auth::user(); $res = array(); $res['success'] = false; $user = Auth::user(); $artist = Artist::where('user_id', $user->id)->first(); if ($request->hasFile('cover')) { //upload an image to the /img/tmp directory and return the filepath. $file = $request->file('cover'); $tmpFilePath = '/uploads/images/original/'; $tmpFileName = 'cover-' . time() . '-' . $file->getClientOriginalName(); //save original file $file = $file->move(public_path() . $tmpFilePath, $tmpFileName); $path = $tmpFilePath . $tmpFileName; //edit image $img = \Image::make($file); $img->backup(); $img->fit(1200, 480); $img->save('uploads/images/large/' . $tmpFileName); // reset image (return to backup state) $img->reset(); $img->fit(360, 144); //360*144 $img->save('uploads/images/thumbnail/' . $tmpFileName); //save image to DB $artist->cover = $tmpFileName; if ($artist->save()) { $res['success'] = true; } } return $res; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $artworks = Artwork::where('artist', $id)->orderBy('created_at')->get(); $artist = Artist::where('id', $id)->first(); return view('artists/show', compact('artworks', 'artist')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $userPriveleges = DB::table('user_privelege')->where('user_id', '=', $id)->delete(); $user = User::findOrFail($id); if ($artist = Artist::where('user_id', '=', $id)->first()) { $artist->user_id = 0; $artist->save(); } $user->delete(); return redirect()->action('UserController@index'); }
/** * Display User Profile Page * * @return View */ public function profile() { $user = Auth::user(); //if not an image url from facebook if (filter_var($user->avatar, FILTER_VALIDATE_URL) === FALSE) { $user->avatar = url('uploads/images/thumbnail/' . $user->avatar); } if (!$user->verified) { session()->flash('warning', 'Please verify your email address!!'); } //if user is artist, load artist profile view if ($user->type == 'artist') { $artist = Artist::where('user_id', $user->id)->first(); $artist->cover = url('uploads/images/large/' . $artist->cover); if (filter_var($artist->user->avatar, FILTER_VALIDATE_URL) === FALSE) { $artist->user->avatar = url('uploads/images/thumbnail/' . $artist->user->avatar); } $isArtistProfile = true; return view('pages.artist', ['user' => $user, 'artist' => $artist, 'isArtistProfile' => $isArtistProfile]); } elseif ($user->type == 'studio') { $studio = Studio::where('user_id', $user->id)->first(); $studio->cover = url('uploads/images/large/' . $studio->cover); return view('pages.studio', ['user' => $user, 'studio' => $studio]); } elseif ($user->type == 'member') { $member = Member::where('user_id', $user->id)->first(); return view('pages.member', ['user' => $user, 'member' => $member]); } else { return redirect('complete-profile')->flash('success', 'Welcome. Please complete your profile..'); } return redirect('/'); }
/** * Remove the specified tattoo from storage. * * @param int $id * @return Response */ public function deleteTattoo(Request $request) { if (!$request->ajax()) { dd("NO ASYNC REQUEST"); } $res = array(); $res['success'] = false; $tattooId = $request->input('tattoo'); $tattoo = Tattoo::find($tattooId); $user = Auth::user(); if ($tattoo) { if ($tattoo->user_id == $user->id) { $tattoo->delete(); $res['success'] = true; } elseif ($user->type == 'artist') { $artist = Artist::where('user_id', $user->id)->first(); $artist->tattoos()->detach($tattooId); $res['success'] = true; } elseif ($user->type == 'studio') { $studio = Studio::where('user_id', $user->id)->first(); $studio->tattoos()->detach($tattooId); $res['success'] = true; } } return $res; }
/** * Display the specified resource. * * @param string $slug * @return Response */ public function show($slug) { // get the artwork by the slug $artwork = Artwork::whereSlug($slug)->first(); $artist = Artist::where('artists.id', '=', $artwork->artist)->first(); if ($artist == null) { $artist['name'] = "-"; $artist['profileLink'] = ""; } else { if ($artist->user_id != 0) { $userProfileSlug = DB::table('users')->where('id', $artist->user_id)->select('slug')->get(); $artist->profileLink = "/users/" . $userProfileSlug[0]->slug; } else { $artist->profileLink = "/artists/show/" . $artist->id; } } $tagArray = $artwork->tagNames(); $reservations = DB::table('reservations')->join('artworks', function ($join) { $join->on('reservations.artwork_id', '=', 'artworks.id')->where('artworks.reserved', '>', 0); })->join('users', function ($join) { $join->on('reservations.user_id', '=', 'users.id'); })->select(['*', DB::raw('users.slug as userSlug'), DB::raw('artworks.slug as artworkSlug'), DB::raw('artworks.id as artworkId'), DB::raw('users.id as userId'), DB::raw('reservations.id as reservationId')])->where('artworks.id', '=', $artwork->id)->get(); if ($artwork) { $tagArray = $artwork->tagNames(); return View::make('artworks/show')->with(compact('artwork', 'tagArray', 'reservations', 'artist')); // get the tags } else { // Show a not found page return View::make('errors/' . HttpCode::NotFound); } }
public function adminUploadTattoosSave(Request $request) { $user = Auth::user(); if ($request->hasFile('file')) { //upload an image to the /img/tmp directory and return the filepath. $file = $request->file('file'); $tmpFilePath = '/uploads/images/original/'; $tmpFileName = 'tattoo-' . time() . '-' . $file->getClientOriginalName(); //save original file $file = $file->move(public_path() . $tmpFilePath, $tmpFileName); $path = $tmpFilePath . $tmpFileName; //edit image $img = \Image::make($file); $img->backup(); // reset image (return to backup state) $img->reset(); $img->fit(360); //240*240 $img->save('uploads/images/thumbnail/' . $tmpFileName); // reset image (return to backup state) $img->reset(); $img->fit(120); //100*100 $img->save('uploads/images/small/' . $tmpFileName); //save tattoo in DB $tattoo = new Tattoo(); $tattoo->title = ''; $tattoo->url = $tmpFileName; $tattoo->description = ''; $tattoo->user_id = $user->id; $tattoo->approved = true; $tattoo->save(); if ($user->type == 'artist') { $profile = Artist::where('user_id', $user->id)->first(); $profile->tattoos()->save($tattoo); } elseif ($user->type == 'studio') { $profile = Studio::where('user_id', $user->id)->first(); $profile->tattoos()->save($tattoo); } return response()->json(array('path' => $tmpFileName), 200); } else { return response()->json(false, 200); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { if (Gate::denies('admin')) { abort(403); } $out = ['form_route' => ['route' => ['track.update', $id], 'method' => 'PUT', 'class' => 'form-horizontal'], 'artist_credit' => []]; $out['track'] = Track::findOrNew((int) $id); $out['genre'] = Genre::orderBy('id')->lists('name', 'id'); if (count(Request::old())) { $old = Request::old(); $out['release'] = Release::find($old['release_id']); if (isset($old['artist_credit']['id'])) { foreach ($old['artist_credit']['id'] as $n => $ac_id) { $artist = Artist::where('id', $ac_id)->firstOrFail(); if (count($artist)) { $out['artist_credit'][$n]['name'] = $artist->name; $out['artist_credit'][$n]['work_type_id'] = $old['artist_credit']['work'][$n]; $out['artist_credit'][$n]['join_phrase'] = $old['artist_credit']['join'][$n]; $out['artist_credit'][$n]['artist_id'] = $old['artist_credit']['id'][$n]; } } } } else { $out['release'] = $out['track']->release; $out['artist_credit'] = $out['track']->credit->credit_name; } $out['work_type'] = WorkType::all(); $out['genres_selected'] = []; foreach ($out['track']->genres as $row) { $out['genres_selected'][] = $row->id; } return view('tracks.form', $out); }
/** * Change Account Basic details * * @param Request $request * @return Response */ public function changeProfile(Request $request) { $this->validate($request, ['current_password' => 'required|min:6']); $user = Auth::user(); if ($user->type == 'studio') { $this->validate($request, ['name' => 'required']); } else { $this->validate($request, ['firstname' => 'required']); } if ($user->email != $request->input('email')) { $this->validate($request, ['email' => 'required|email|max:255|unique:users']); } if ($user->contact != $request->input('contact')) { $this->validate($request, ['contact' => 'required|digits:10']); } if (Hash::check($request->input('current_password'), $user->password)) { if ($user->type == 'artist') { $artist = Artist::where('user_id', $user->id)->first(); $artist->firstname = $request->input('firstname'); $artist->lastname = ''; $artist->save(); $user->name = $request->input('firstname'); } elseif ($user->type == 'member') { $member = Member::where('user_id', $user->id)->first(); $member->firstname = $request->input('firstname'); $member->lastname = ''; $member->save(); $user->name = $request->input('firstname'); } elseif ($user->type == 'studio') { $studio = Studio::where('user_id', $user->id)->first(); $studio->title = ''; $studio->name = $request->input('name'); $studio->save(); $user->name = $request->input('name'); } $user->email = $request->input('email'); $user->contact = $request->input('contact'); $user->save(); return redirect('profile#edit')->with('success', 'Profile changed successfully!'); } return redirect('profile#edit')->with('warning', 'Wrong Password!'); }
public function artist() { return Artist::where('name', '=', $this->artist_name); }
public function search($str) { $out = Artist::where('name', 'LIKE', $str . '%')->get(['id', 'name', 'artist_type_id', 'gender']); foreach ($out as &$row) { $row->type = $row->type()->first()->name; } return $out; }
/** * reate a artist studio * * @return View */ public function createStudio(Request $request) { //dd($request); $user = Auth::user(); $artist = Artist::where('user_id', $user->id)->first(); if (Studio::where('user_id', $user->id)->first()) { return redirect('profile#studios')->with('error', 'Multiple Studios are not allowed.'); } $studio = new Studio(); $studio->user_id = $user->id; $studio->name = $request->input('name'); $studio->title = ''; if ($studio->save()) { $artist->studios()->attach($studio->id); session()->flash('success', 'Studio Created. Now Complete studio\'s profile.'); $data['name'] = $studio->name; $data['type'] = 'studio'; $data['contact'] = $user->contact; $data['email'] = $user->email; Mail::send('emails.admin_notification_signup', $data, function ($message) use($data) { $message->from('*****@*****.**', "Tattoo Cultr"); $message->subject("New Studio Signup"); $message->to(env('ADMIN_EMAIL')); }); } else { session()->flash('error', 'Error! Please try again..'); } return redirect('studio/' . $studio->user->slug); }