コード例 #1
0
 public function update(Song $song, Request $request)
 {
     //$song->title = $request->get('title');
     //$song->save();
     $song->fill(['title' => $request->get('title')])->save();
     return redirect('songs');
 }
コード例 #2
0
 public function update(Song $song, Request $request)
 {
     //        $song = $this->song->where('slug',$slug)->first();
     //        $song->title = $request->get('title');
     //        $song->save();
     $song->fill($request->input())->save();
     return redirect('songs');
 }
コード例 #3
0
 public function update(Song $song, Request $request)
 {
     // $song->TitleSong = $request->get('TitleSong');
     // $song->save();
     // $song->fill(['TitleSong'=>$request->get('TitleSong')])->save();
     $song->fill($request->input())->save();
     return redirect()->route('songs_path');
 }
コード例 #4
0
 public function store(Song $songs)
 {
     $songs->title = \Request::get('title');
     $songs->lyrics = \Request::get('lyrics');
     $songs->slug = \Request::get('slug');
     $songs->save();
     $file = \Request::file('myname');
     $imageName = $songs->slug . '.' . $file->getClientOriginalExtension();
     \Request::file('myname')->move(base_path() . '/public/images/catalog/', $imageName);
     return Redirect('songs');
 }
コード例 #5
0
ファイル: SongsController.php プロジェクト: kcpal/laravel
 public function update(Song $song, Request $request)
 {
     //        $song = $this->song->whereSlug($slug)->first();
     //        $song->fill(['title' => $request->get('title')])->save();
     $song->fill($request->input())->save();
     //        $song->title = $request->get('title');
     //
     //        $song->save();
     return redirect('songs');
     //        return 'Update the song.';
 }
コード例 #6
0
 public function listen()
 {
     $session_id = Session::getId();
     // Get the first song in the queue
     $song = new Song(MusicQueue::dequeue());
     // Make sure there isn't an error in the song class (for some reason)
     if ($song->error()) {
         return "error";
     } else {
         // Listen to the song :)
         return view('listening', ['song' => $song]);
     }
 }
コード例 #7
0
 public function random()
 {
     //
     $song = Song::random();
     $data = ["song" => $song->song_id, "name" => $song->song_name, "path" => $song->song_path, "author" => $song->song_authors, "is_love" => false, "image" => $song->song_image];
     return response()->json($data);
 }
コード例 #8
0
 /**
  * 用于接收歌曲上传数据
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function songUpload(Request $request)
 {
     /**
      * 歌曲上传时附带的点歌信息
      *
      * @var Object $msgObj
      * @property string singer
      * @property string songName
      * @property string toWho
      * @property string contest
      * @property string pointPerson
      * @property \DateTime time
      * @property integer vote
      */
     $msgObj = json_decode($request->get('message'));
     if (!is_object($msgObj)) {
         return response()->json('信息未提供完整,无法上传。', 403);
     }
     $song = new Song();
     $file = $request->file('mis');
     if ($file->getError() !== 0) {
         return response()->json($file->getErrorMessage(), 500);
     }
     $filename = $msgObj->singer . '-' . $msgObj->songName . '.' . (empty($file->getExtension()) ? mb_substr($file->getClientOriginalName(), mb_strpos($file->getClientOriginalName(), '.') + 1) : $file->getExtension());
     if (!Storage::disk('local')->put('songs/' . $filename, file_get_contents($file->getRealPath()))) {
         return response()->json('文件保存失败,请联系服务器管理员', 500);
     }
     $song->song_name = $msgObj->songName;
     $song->song_singer = $msgObj->singer;
     $song->song_reference = Storage::url($filename);
     $song->song_size = $file->getSize();
     $song->saveOrFail();
 }
コード例 #9
0
 public function search(Request $request)
 {
     // keyword to search
     $keyword = $request->input('keyword');
     // filter songs by keyword
     $songs = Song::where('songname', 'LIKE', "%{$keyword}%")->get();
     return $songs;
 }
コード例 #10
0
 /**
  * @param $slug
  * @return string
  */
 public function update($slug)
 {
     /*dd(Song::where('slug', $slug)->first()->toArray());*/
     /*$song = Song::where('slug', $slug)->first();
       $song->title = Input::get('title');
       $song->lyrics = Input::get('lyrics');
       $song->save();*/
     Song::where('slug', $slug)->first()->fill(['title' => Input::get('title'), 'lyrics' => Input::get('lyrics')])->save();
     return redirect('songs');
 }
コード例 #11
0
 public function select($id)
 {
     if (Auth::check()) {
         $song = \App\Song::find($id);
         $this->push($song->url_source);
         return redirect('playlists');
     } else {
         return redirect(url());
     }
 }
コード例 #12
0
 public function Listen($song_id)
 {
     $song = Song::find($song_id);
     if (count($song)) {
         $song->listen_count++;
         $song->save();
         return Response()->json(array('data' => $song), 200);
     } else {
         return Response()->json(array('message' => 'Song not Found'), 404);
     }
 }
コード例 #13
0
ファイル: Playlist.php プロジェクト: ritey/audious
 /**
  * Listen on delete event. When Playlist model is deleted, delete all
  * associated songs.
  */
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($playlist) {
         // Get song ids.
         $song_ids = $playlist->songs->pluck('id')->toArray();
         if (!empty($song_ids)) {
             Song::destroy($song_ids);
         }
     });
 }
コード例 #14
0
 public function update($slug, Request $request)
 {
     //dd(\Request::input());
     $song = Song::whereSlug($slug)->first();
     //$song->title = $request->get('title');
     //$song->fill(['title'=>$request->get('title')])->save();
     //tambem serve
     $song->fill($request->input())->save();
     //$song->save();
     return redirect('songs');
 }
コード例 #15
0
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     //мои модели
     Song::saving(function ($songs) {
         $songs['user_id'] = Auth::user()->id;
     });
     /*Song::deleting(function ($songs) {
           $path = 'media/upload/' . $songs->picture;
           if (file_exists($path)) {
               @unlink($path);
           }
       });*/
     //
 }
コード例 #16
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Blade::directive('datetime', function ($expression) {
         return "<?php echo explode(' ', trim({$expression}, '()'))[0]; ?>";
     });
     Blade::directive('filesize', function ($expression) {
         return "<?php echo '[' . round({$expression} / 1024 / 1024, 2) . 'M]'; ?>";
     });
     Album::saved(function () {
         return response()->json('成功上传!');
     });
     Song::saved(function () {
         return response()->json('成功上传!');
     });
 }
コード例 #17
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     //$router->model('article', 'App\Article');//
     $router->bind('article', function ($id) {
         return \App\Article::published()->findOrFail($id);
     });
     //$router->model('tags', 'App\Tag');
     $router->bind('tags', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
     $router->bind('songs', function ($slug) {
         //return App\Song::whereSlug($slug)->first();//App\Song::where('slug', $slug)->first()
         return \App\Song::where('slug', $slug)->firstOrFail();
     });
 }
コード例 #18
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex()
 {
     $song = \App\Song::find($_GET['id']);
     return view('templates.ajaxsong')->with('song', $song);
 }
コード例 #19
0
ファイル: GameController.php プロジェクト: kodumen/mbeat
 /**
  * Show the game.
  *
  * @param $id
  * @param $difficulty
  * @return string
  */
 public function play($id, $difficulty)
 {
     $song = Song::getInfo($id);
     return view('game.play', ['id' => $id, 'difficulty' => $difficulty, 'song' => $song]);
 }
コード例 #20
0
ファイル: Songs.php プロジェクト: jabrankhalil/laravel
 public function show($id)
 {
     $song_name = Song::find($id);
     return view('songs.show', compact('song_name'));
 }
コード例 #21
0
ファイル: SongController.php プロジェクト: suowei/saoju
 public function favorites($id)
 {
     $song = Song::find($id, ['id', 'title']);
     $favorites = Songfav::with(['user' => function ($query) {
         $query->select('id', 'name');
     }])->select('user_id', 'created_at')->where('song_id', $id)->orderBy('created_at')->paginate(20);
     return view('song.favorites', ['song' => $song, 'favorites' => $favorites]);
 }
コード例 #22
0
 public function postEdit(SongRequest $r, $id = null)
 {
     $r['user_id'] = Auth::user()->id;
     Song::where('id', $id)->where('user_id', Auth::user()->id)->update($r->except('_token'));
     //return redirect('cabinet');
 }
コード例 #23
0
 public function EditMySong()
 {
     $song_id_edit = Input::get('song_id_edit');
     $singer_name_input = Input::get('singer_name_input');
     $song_name_input = Input::get('song_name_input');
     $image_change = Input::file('image_change');
     if ($image_change != null) {
         $filename = $image_change->getClientOriginalName();
         $path = public_path('uploadedImage/');
         $flnm = str_replace(' ', '', $filename);
         $image_url = 'uploadedImage/' . $flnm;
         $song = Song::find($song_id_edit);
         if (count($song) && $image_change->move($path, $flnm)) {
             $song->singer = $singer_name_input;
             $song->song_name = $song_name_input;
             $song->image_url = $image_url;
             $song->save();
         }
     } else {
         $song = Song::find($song_id_edit);
         if (count($song)) {
             $song->singer = $singer_name_input;
             $song->song_name = $song_name_input;
             $song->save();
         }
     }
     return Redirect::Route('edit-songs');
 }
コード例 #24
0
ファイル: SongrevController.php プロジェクト: suowei/saoju
 public function create(Request $request)
 {
     $song = Song::find($request->input('song'), ['id', 'title']);
     return view('songrev.create', ['song' => $song]);
 }
コード例 #25
0
ファイル: IndexController.php プロジェクト: suowei/saoju
 public function zhoubian()
 {
     $newsongs = Song::select('id', 'title', 'alias', 'artist')->orderBy('id', 'desc')->take(15)->get();
     $songrevs = Songrev::with(['user' => function ($query) {
         $query->select('id', 'name');
     }, 'song' => function ($query) {
         $query->select('id', 'title');
     }])->orderBy('id', 'desc')->take(10)->get();
     $hotrevsongs = Songrev::with(['song' => function ($query) {
         $query->select('id', 'title', 'artist');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as review_count, song_id'))->groupBy('song_id')->orderBy('review_count', 'desc')->take(15)->get();
     $hotfavsongs = Songfav::with(['song' => function ($query) {
         $query->select('id', 'title', 'artist');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as favorite_count, song_id'))->groupBy('song_id')->orderBy('favorite_count', 'desc')->take(15)->get();
     $newcreatedfteps = Ftep::with(['ft' => function ($query) {
         $query->select('id', 'title', 'host');
     }])->select('id', 'ft_id', 'title', 'release_date')->orderBy('id', 'desc')->take(10)->get();
     $ftrevs = Ftrev::with(['user' => function ($query) {
         $query->select('id', 'name');
     }, 'ft' => function ($query) {
         $query->select('id', 'title');
     }, 'ftep' => function ($query) {
         $query->select('id', 'title');
     }])->orderBy('id', 'desc')->take(10)->get();
     $hotrevfts = Ftrev::with(['ft' => function ($query) {
         $query->select('id', 'title');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as review_count, ft_id'))->groupBy('ft_id')->orderBy('review_count', 'desc')->take(10)->get();
     $hotfavfts = Ftfav::with(['ft' => function ($query) {
         $query->select('id', 'title');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as favorite_count, ft_id'))->groupBy('ft_id')->orderBy('favorite_count', 'desc')->take(10)->get();
     $todaylives = Live::select('id', 'title', 'showtime')->whereRaw('date(showtime) = curdate()')->orderBy('showtime')->get();
     $newlives = Live::select('id', 'title', 'showtime')->orderBy('id', 'desc')->take(15)->get();
     $liverevs = Liverev::with(['user' => function ($query) {
         $query->select('id', 'name');
     }, 'live' => function ($query) {
         $query->select('id', 'title', 'showtime');
     }])->orderBy('id', 'desc')->take(10)->get();
     $hotrevlives = Liverev::with(['live' => function ($query) {
         $query->select('id', 'title', 'showtime');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as review_count, live_id'))->groupBy('live_id')->orderBy('review_count', 'desc')->take(15)->get();
     $hotfavlives = Livefav::with(['live' => function ($query) {
         $query->select('id', 'title', 'showtime');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as favorite_count, live_id'))->groupBy('live_id')->orderBy('favorite_count', 'desc')->take(15)->get();
     return view('zhoubian', ['newsongs' => $newsongs, 'songrevs' => $songrevs, 'hotrevsongs' => $hotrevsongs, 'hotfavsongs' => $hotfavsongs, 'newcreatedfteps' => $newcreatedfteps, 'ftrevs' => $ftrevs, 'hotrevfts' => $hotrevfts, 'hotfavfts' => $hotfavfts, 'todaylives' => $todaylives, 'newlives' => $newlives, 'liverevs' => $liverevs, 'hotrevlives' => $hotrevlives, 'hotfavlives' => $hotfavlives]);
 }
コード例 #26
0
ファイル: UserController.php プロジェクト: tomHash/sc
 /**
  * Return user song by slug
  *
  * @return \Illuminate\Http\Response 
  **/
 public function song($userSlug, $songSlug)
 {
     $song = Song::findBySlugOrIdOrFail($songSlug);
     $user = User::findBySlugOrIdOrFail($userSlug);
     return view('users.song', ['song' => $song, 'user' => $user]);
 }
コード例 #27
0
ファイル: routes.php プロジェクト: kronzeuge/laravel-5.2.0
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use App\Song;
Route::get('/', function () {
    return view('welcome');
});
Route::get('songs', function () {
    ## 1. Variante um einen Datensatz zu erstellen
    $song = new Song();
    $song->titel = 'Pump Up The Jam';
    $song->save();
    ## 2. Variante direkt
    ## Achtung im Model muss protected $fillable (white list) oder $guarded (black list) gesetzt sein
    $noch_ein_song = Song::create(['titel' => 'What a wonderful world']);
    return Song::all();
    //alle songs
    //return Song::find(1); //song mit id 1
});
## Anonyme Funktion mit Parametern innerhalb der URL
Route::get('/Benutzer/{name}', function ($user) {
    return 'Hallo ' . $user;
});
## About mit einer einfachen View mit übergebenen Werten
Route::get('/About', function () {
コード例 #28
0
 /**
  * Save new tracks to db.
  */
 private function syncUpdate($request, $service, $all_music)
 {
     foreach ($all_music as $playlist_name => $tracks) {
         // Get playlist.
         $playlist = Playlist::getPlaylist($playlist_name, ucfirst($service->name));
         // If playlist not in DB - add.
         if (empty($playlist)) {
             $playlist = Auth::user()->playlists()->create(['name' => $playlist_name, 'service_id' => $service->id]);
         }
         // Get list of existing songs in db.
         $song_identifier_in_db = $this->extractPlaylistSongIds($playlist);
         foreach ($tracks as $track) {
             // If song already in db, skip and remove from array of existing ids.
             if (isset($song_identifier_in_db[$track->id])) {
                 unset($song_identifier_in_db[$track->id]);
                 continue;
             }
             // Create new song.
             $playlist->songs()->firstOrCreate(['title' => $track->title, 'song_identifier' => $track->id, 'image' => $track->artwork_url, 'url' => $track->permalink_url, 'song_created' => $track->created_at, 'service_id' => $service->id]);
         }
         // Check if any songs left in songs list from db. If so, remove thos songs from db.
         if (!empty($song_identifier_in_db)) {
             $song_identifier_in_db = collect($song_identifier_in_db);
             $ids = $song_identifier_in_db->keyBy('id')->keys();
             Song::destroy($ids);
         }
     }
     // Delete deleted playlists including songs.
     Playlist::deletePlaylist(array_keys($all_music), $service->id);
 }
コード例 #29
0
 public function playlist($id)
 {
     $url = "http://music.163.com/api/playlist/detail?id={$id}";
     $refer = "http://music.163.com/";
     $header[] = "Cookie: appver=2.0.2;";
     $response = json_decode(http_get($url), true);
     if ($response["code"] == 200 && $response["result"]) {
         //处理音乐信息
         $result = $response["result"]["tracks"];
         $collect = [];
         foreach ($result as $k => $value) {
             $mp3_url = str_replace("http://m", "http://p", $value["mp3Url"]);
             $song_cover = '';
             $artists = [];
             foreach ($value["artists"] as $artist) {
                 $artists[] = $artist["name"];
             }
             if ($value['album']['picUrl']) {
                 $song_cover = $value['album']['picUrl'];
             }
             $artists = implode(",", $artists);
             $song = ["song_name" => $value["name"], "song_path" => $mp3_url, "song_authors" => $artists, "song_image" => $song_cover, "song_source" => 2, "song_language" => 1, "song_style" => 1, "song_moods" => 1];
             $row = Song::where('song_path', $mp3_url)->first();
             if (empty($row)) {
                 $row = Song::create($song);
             }
             $collect[] = $row;
         }
         return $collect;
     }
 }
コード例 #30
0
|
*/
Route::get('/', function () {
    return view('welcome');
});
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
/**
 * Handle facebook authentication
 */
Route::get('auth/fbauth', 'Auth\\AuthController@redirectToProvider');
Route::get('callback', 'Auth\\AuthController@handleProviderCallback');
/**
 *
 *
 */
Route::resource('listeners', 'ListenerController');
Route::resource('albums', 'AlbumController');
Route::resource('songs', 'SongController');
Route::resource('artists', 'ArtistController');
/**
 * used for ajax call to retrieve the songs based on album id
 *
 *
 */
Route::get('/ajax-call', function () {
    $id = Input::get('album_id');
    $songs = \App\Song::where('album_id', '=', $id)->get();
    return Response::json($songs);
});