예제 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $artist = \App\Artist::find($id);
     $name = \Input::get('name');
     $artist->name = $name;
     $artist->save();
     return redirect('artists');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($id)
 {
     if (Auth::check()) {
         $artist = \App\Artist::find($id);
         $name = \Input::get('name');
         $artist->name = $name;
         $artist->save();
         return redirect('artists');
     } else {
         return redirect(url());
     }
 }
 /**
  * Display the specified artist.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $artist = Artist::find($id);
     $user = Auth::user();
     $isArtistProfile = false;
     $isFollowing = false;
     if (Auth::check()) {
         if ($artist->user_id == Auth::User()->id) {
             $isArtistProfile = true;
         }
         if (Follow::where('artist_id', $artist->id)->where('user_id', $user->id)->count()) {
             $isFollowing = true;
         }
     }
     //if not an image url from facebook
     if (filter_var($artist->user->avatar, FILTER_VALIDATE_URL) === FALSE) {
         $artist->user->avatar = url('uploads/images/thumbnail/' . $artist->user->avatar);
     }
     $artist->cover = url('uploads/images/large/' . $artist->cover);
     return view('pages.artist', ['artist' => $artist, 'isArtistProfile' => $isArtistProfile, 'isFollowing' => $isFollowing]);
 }
 /**
  * Upload Tattoo
  *
  * @return View
  */
 public function uploadTattoo(Request $request)
 {
     $user = Auth::user();
     if ($request->hasFile('tattoo')) {
         //upload an image to the /img/tmp directory and return the filepath.
         // dd($request);
         $file = $request->file('tattoo');
         $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 = $request->input('title');
         $tattoo->url = $tmpFileName;
         $tattoo->description = $request->input('description');
         $tattoo->user_id = $user->id;
         $tattoo->approved = false;
         if ($request->input('type') == 'member') {
             if ($request->input('id') == $user->id) {
                 $tattoo->approved = false;
                 //member - self tattoos ll never be approved for public place, only visible to member page(always, no approval needed)
                 $tattoo->save();
             }
             return redirect('member/' . $request->input('id'))->with('success', "Successfully uploaded!");
         } elseif ($request->input('type') == 'artist') {
             $artist = Artist::find($request->input('id'))->first();
             //if uploaded by self
             if ($artist->user->id == $user->id) {
                 $tattoo->approved = true;
             }
             $artist->tattoos()->save($tattoo);
             return redirect('artist/' . $request->input('id'))->with('success', "Successfully uploaded!");
         } elseif ($request->input('type') == 'studio') {
             $studio = Studio::find($request->input('id'))->first();
             //if uploaded by self
             if ($studio->user->id == $user->id) {
                 $tattoo->approved = true;
             }
             $studio->tattoos()->save($tattoo);
             return redirect('studio/' . $request->input('id'))->with('success', "Successfully uploaded!");
         } else {
             session()->flash('error', "Error in uploading tattoo!! Please try again..");
         }
     } else {
         session()->flash('error', "Please select a file!!");
     }
     return redirect('/');
 }
예제 #5
0
 /**
  * Upload Tattoo
  *
  * @return View
  */
 public function uploadFromHome(Request $request)
 {
     $user = Auth::user();
     if ($request->hasFile('tattoo')) {
         //upload an image to the /img/tmp directory and return the filepath.
         //dd($request);
         $file = $request->file('tattoo');
         $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);
         $img->destroy();
         //save tattoo in DB
         $tattoo = new Tattoo();
         $tattoo->title = $request->input('title');
         $tattoo->url = $tmpFileName;
         $tattoo->description = $request->input('description');
         $tattoo->user_id = $user->id;
         $tattoo->approved = false;
         $tattooArtist = Artist::find($request->input('artist'));
         if ($tattooArtist) {
             $tattooArtist->tattoos()->save($tattoo);
             if ($request->input('tags')) {
                 $tattoo->tags_count = 1;
                 $tattoo->tags()->sync($request->input('tags'));
                 $tattoo->save();
             }
             session()->flash('success', "Tattoo request has been sent to artist for approval!!");
         } else {
             session()->flash('error', "Artist not found!!");
         }
     } else {
         session()->flash('error', "Please select a file!!");
     }
     return Redirect::back();
 }
예제 #6
0
 /**
  * Send Follow Request
  *
  * @return View
  */
 public function UnfollowArtist($id)
 {
     $user = Auth::user();
     $artist = Artist::find($id);
     if ($artist) {
         $follow = Follow::where('artist_id', $id)->where('user_id', $user->id)->first();
         $follow->delete();
         return redirect('artist/' . $artist->id)->with('success', 'You Unfollowed ' . $artist->user->firstname);
     }
     return redirect('artist/' . $artist->id);
 }
예제 #7
0
 public function update(Request $request, $id)
 {
     $art = Artist::find($id);
     $art->fill($request->input())->save();
     return redirect('artist');
 }
예제 #8
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(TrackRequest $request, $id)
 {
     if (Gate::denies('admin')) {
         abort(403);
     }
     $track = Track::find($id);
     // Old track data
     $req = $request->all();
     // Request data
     $genre = [];
     // genre list
     $genre_old = [];
     // genre list
     foreach ($req['genre'] as $n => $genre_id) {
         $genre[$n] = GenreTrack::where('track_id', $id)->where('genre_id', $genre_id)->first();
         if ($genre[$n] == null) {
             $genre_new = ['genre_id' => $genre_id, 'track_id' => $id];
             $genre[$n] = new GenreTrack($genre_new);
             $genre[$n]->save();
         }
         $genre_old[] = $genre[$n]->id;
     }
     GenreTrack::where('track_id', $id)->whereNotIn('id', $genre_old)->delete();
     $ac = [];
     // list of ArtistCreditNames
     $ac_old = [];
     // List of artist credit names that already exist
     $artists = [];
     // List of artists, just for counting
     foreach ($req['artist_credit']['work'] as $n => $work_id) {
         $artist_id = $req['artist_credit']['id'][$n];
         $join_phrase = $req['artist_credit']['join'][$n];
         $artists[$artist_id] = $join_phrase . ' ' . Artist::find($artist_id)->name;
         // artiat counter
         // Checking if ArtistCreditName already exists
         $ac[$artist_id . '_' . $work_id . '_' . $join_phrase] = ArtistCreditName::where('work_type_id', (int) $work_id)->where('artist_id', $artist_id)->where('join_phrase', $join_phrase)->where('artist_credit_id', $track->credit->id)->first();
         if ($ac[$artist_id . '_' . $work_id . '_' . $join_phrase] == null) {
             // Creating new ArtistCreditName
             $ac_new = ['artist_credit_id' => $track->credit->id, 'artist_id' => $artist_id, 'work_type_id' => $work_id, 'position' => '', 'name' => Artist::find($artist_id)->name, 'join_phrase' => $join_phrase];
             $ac[$artist_id . '_' . $work_id . '_' . $join_phrase] = new ArtistCreditName($ac_new);
         }
         // Sets position. Not important for now there is no ordering in form
         // TODO make ordering in form
         $ac[$artist_id . '_' . $work_id . '_' . $join_phrase]->position = $n;
         // Saving ArtistCreditNames
         $ac[$artist_id . '_' . $work_id . '_' . $join_phrase]->save();
         // preventing deleting of used ArtistCreditNAmes
         $ac_old[] = $ac[$artist_id . '_' . $work_id . '_' . $join_phrase]->id;
     }
     // Delete not used ArtistCreditNames
     ArtistCreditName::where('artist_credit_id', $track->credit->id)->whereNotIn('id', $ac_old)->delete();
     $track->credit->artist_count = count($artists);
     $track->credit->ref_count = count($ac);
     $track->credit->name = trim(implode(' ', $artists), ' &');
     $track->credit->save();
     // Saving track data
     $track->update($req);
     // Redirect back to Show with message
     return redirect()->route('track.show', ['track' => $id])->with('alert-success', [trans('htmusic.saved')]);
 }
예제 #9
0
 public function show($id)
 {
     $artist = Artist::find($id);
     $artist->load('labels');
     return $artist;
 }
예제 #10
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(ArtistRequest $request, $id)
 {
     if (Gate::denies('admin')) {
         abort(403);
     }
     Artist::find($id)->update($request->all());
     return redirect()->route('artist.show', ['artist' => $id])->with('alert-success', [trans('htmusic.saved')]);
 }
예제 #11
0
파일: Cd.php 프로젝트: hungnt167/CDShop
 public function getDataAProduct($id, $column)
 {
     $models = DB::table('cds')->join('artists', 'cds.singer_id', '=', 'artists.id')->join('format_cds', 'cds.format_id', '=', 'format_cds.id')->join('types', 'cds.type_id', '=', 'types.id')->leftJoin('price_groups', 'cds.group_price_id', '=', 'price_groups.id')->where('cds.id', $id)->select($column)->first();
     $composer = Artist::find($models->composer_id)->first();
     $models->composer_id = $composer->id;
     $models->composer = $composer->name;
     if ($models->price <= 0) {
         $models->price = $models->price_group;
         $models->sale_off = $models->sale_off_group;
     }
     return json_encode($models);
 }
예제 #12
0
 /**
  * Display the review page
  * @param  int  $id
  * @return Response
  */
 public function artistReviews($id, Request $request)
 {
     if (!$request->ajax()) {
         dd("NO ASYNC REQUEST");
     }
     $artist = Artist::find($id);
     $reviews = Review::where('user_id', $artist->user->id)->orderBy('created_at', 'desc')->get();
     $isArtistProfile = false;
     if (Auth::check()) {
         if ($artist->user_id == Auth::User()->id) {
             $isArtistProfile = true;
         }
     }
     return view('ajax.reviews', ['profile' => $artist, 'isSelf' => $isArtistProfile, 'reviews' => $reviews]);
 }
예제 #13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Artist::find($id)->delete();
     return redirect('artists');
 }
예제 #14
0
 /**
  * Display artist Studios
  *
  * @return View
  */
 public function artistStudio($id)
 {
     $artist = Artist::find($id);
     $user = Auth::user();
     $isArtistProfile = false;
     $isFollowing = false;
     if (Auth::check()) {
         if ($artist->user_id == Auth::User()->id) {
             $isArtistProfile = true;
         }
         if (Follower::where('user_id', $artist->user->id)->where('follower_id', $user->id)->count()) {
             $isFollowing = true;
         }
     }
     $artist->cover = url('uploads/images/large/' . $artist->cover);
     return view('pages.artist_studio', ['artist' => $artist, 'isArtistProfile' => $isArtistProfile, 'isFollowing' => $isFollowing]);
 }