public function store(Requests\CreateSongRequest $request, Song $song)
 {
     $input = $request->all();
     $song->create($input);
     // $song->create($request->all->());
     return redirect()->route('songs_path');
 }
 public function postIndex(SongRequest $r)
 {
     $r['user_id'] = Auth::user()->id;
     $pic = \App::make('\\App\\Libs\\Img')->url(Input::file('picture1'));
     if ($pic) {
         $r['picture'] = $pic;
     } else {
         $r['picture'] = '-';
     }
     Song::create($r->all());
     return redirect('cabinet');
 }
Beispiel #3
0
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|max:255', 'alias' => 'max:255', 'artist' => 'required|max:255', 'url' => 'url', 'poster_url' => 'url', 'staff' => 'required']);
     if ($song = Song::create(Input::all())) {
         Songver::create(['song_id' => $song->id, 'user_id' => $request->user()->id, 'first' => 1, 'title' => $song->title, 'alias' => $song->alias, 'artist' => $song->artist, 'url' => $song->url, 'poster_url' => $song->poster_url, 'staff' => $song->staff, 'lyrics' => $song->lyrics]);
         if ($request->has('drama_id')) {
             Ed::create(['drama_id' => $request->input('drama_id'), 'episode_id' => $request->has('episode_id') ? $request->input('episode_id') : 0, 'song_id' => $song->id, 'user_id' => $request->user()->id]);
         }
         return redirect()->route('song.show', [$song]);
     } else {
         return redirect()->back()->withInput()->withErrors('添加失败');
     }
 }
Beispiel #4
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;
     }
 }
Beispiel #5
0
| 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 () {
    ## Array Deklaration in vereinfachter Schreibweise seit PHP 5.4
    $fw = ['name' => 'Laravel', 'version' => '5.1.11', 'notes' => 'Mein erster Eindruck ist <b>sehr gut</b>!'];
    ## Variante 1: Übergabe der Variable $fb mit with
    //return view ('about')->with('framework', $fw);
    ## Variante 2: Vereinfachte Übergabe
 public function store(CreateSongRequest $request)
 {
     Song::create($request->all());
     return redirect('songs');
 }
Beispiel #7
0
 public function store(CreateSongRequest $request, Song $song)
 {
     //        $input = $request->all();
     $song->create($request->all());
     return redirect()->route('songs.index');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateSongRequest $request, Song $song)
 {
     $song->create($request->all());
     return redirect()->route('songs_path');
 }
Beispiel #9
0
 /**
  * Persist a new song
  *
  * @param Requests\CreateSongRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(Requests\CreateSongRequest $request)
 {
     $this->song->create($request->all());
     return redirect()->route('song.index');
 }