当前位置: 首页>>代码示例>>PHP>>正文


PHP Song::create方法代码示例

本文整理汇总了PHP中Song::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Song::create方法的具体用法?PHP Song::create怎么用?PHP Song::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Song的用法示例。


在下文中一共展示了Song::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created song in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Set rules for validator
     $rules = array("artist" => "required", "title" => "required", "requester" => "required", "link" => "required|url");
     // Validate input
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         // TODO: Remember form input...
         return Redirect::to('song/create')->withErrors($validator, "song");
     }
     // Create new song
     $song = Input::all();
     // Set or unset remember cookie
     if (isset($song['remember-requester'])) {
         $cookie = Cookie::make("requester", $song['requester']);
     } else {
         $cookie = Cookie::forget("requester");
     }
     $artist = DB::getPdo()->quote($song['artist']);
     $title = DB::getPdo()->quote($song['title']);
     if (Song::whereRaw("LOWER(artist) = LOWER({$artist}) AND LOWER(title) = LOWER({$title})")->count() > 0) {
         return Redirect::to('song/create')->with('error', "HEBBEN WE AL!!!")->withCookie($cookie);
     }
     Song::create($song);
     // Set success message
     $msg = "Gefeliciteerd! Je nummer is aangevraagd :D";
     // Redirect to song index page with message and cookie
     return Redirect::to("/")->with("success", $msg)->withCookie($cookie);
 }
开发者ID:SanderVerkuil,项目名称:molenpark,代码行数:34,代码来源:SongsController.php

示例2: Song

<?php

//ini_set("display_errors", 1);
require __DIR__ . '/autoload.php';
//create new Songs
$model = new Song();
$model->status = 2;
$model->rate = 66;
$model->save(3);
$model = new Song(['title' => 'I can teach you', 'artist' => 'bon jovi', 'status' => 1]);
$model->create();
开发者ID:sintret,项目名称:freelancer,代码行数:11,代码来源:update.php


注:本文中的Song::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。