Esempio n. 1
0
 /**
  * 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);
 }
Esempio n. 2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     if (Gate::denies('admin')) {
         abort(403);
     }
     // TODO "Add Image" button
     $out = ['form_route' => ['route' => ['image.update', $id], 'method' => 'PUT', '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 {
         $out['image'] = Image::findOrNew($id);
     }
     return view('images.form', $out);
 }
Esempio n. 3
0
 public function search($str)
 {
     $out = Release::where('name', 'LIKE', $str . '%')->get(['id', 'name', 'artist_credit_id']);
     foreach ($out as &$row) {
         $row->artist = $row->credit()->first()->name;
     }
     return $out;
 }