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


PHP models\Author类代码示例

本文整理汇总了PHP中app\models\Author的典型用法代码示例。如果您正苦于以下问题:PHP Author类的具体用法?PHP Author怎么用?PHP Author使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: run

 /**
  * Seeds the table.
  *
  * @return void
  */
 public function run()
 {
     $author = new Author();
     $author->first_name = 'Dan';
     $author->last_name = 'Gebhardt';
     $author->twitter = 'dgeb';
     $author->save();
 }
开发者ID:guduchango,项目名称:limoncello-collins,代码行数:13,代码来源:AuthorsTableSeeder.php

示例2: actionIndex

 public function actionIndex()
 {
     $searchModel = new SearchBook();
     $author = new Author();
     $author->surname = '';
     $authors_data = $author->find()->select(['id', "name"])->all();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'author' => $author, 'authors_data' => $authors_data]);
 }
开发者ID:uaman89,项目名称:library,代码行数:9,代码来源:BookController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $result = Validator::make(Input::all(), ['title' => 'required', 'author' => 'required', 'publisher' => 'required', 'isbn' => "required|max:13|min:13|regex:/^[1-9][0-9]{12}\$/"], ['title.required' => 'Book title is required', 'author.required' => 'Book author is required', 'isbn.required' => 'ISBN is required', 'isbn.max' => 'ISBN must be exactly 13 characters', 'isbn.min' => 'ISBN must be exactly 13 characters', 'isbn.regex' => 'ISBN must contain numbers only.', 'publisher.required' => 'Publisher is required']);
     if ($result->fails()) {
         $result->errors()->add('submitted', 1);
         $result->errors()->add('desc', Input::get('description') !== "" ? TRUE : FALSE);
         return redirect()->route('books.new')->withErrors($result->errors())->withInput();
     }
     $author_id = $request->get('author_id');
     if (intval($author_id) == -1) {
         $new_author = new Author();
         $new_author->author_name = $request->get('author');
         $new_author->save();
         $author_id = $new_author->id;
         // Create copy of newly created author
         $new_author = new Author();
         $new_author->author_name = $request->get('author');
         $new_author->record_id = $author_id;
         $new_author->save();
     }
     $publisher_id = $request->get('publisher_id');
     if (intval($publisher_id) == -1) {
         $new_publisher = new Publisher();
         $new_publisher->name = $request->get('publisher');
         $new_publisher->save();
         $publisher_id = $new_publisher->id;
         // Create copy of newly created publisher
         $new_publisher = new Publisher();
         $new_publisher->name = $request->get('publisher');
         $new_publisher->record_id = $publisher_id;
         $new_publisher->save();
     }
     $book = new Books();
     $book->title = $request->get("title");
     $book->author_id = $author_id;
     $book->publisher_id = $publisher_id;
     $book->isbn = $request->get("isbn");
     $book->description = $request->get('description');
     $book->date_published = $request->get('date_published');
     $book->save();
     $book_id = $book->id;
     // Create copy of newly created book
     $book = new Books();
     $book->title = $request->get("title");
     $book->author_id = $author_id;
     $book->publisher_id = $publisher_id;
     $book->isbn = $request->get("isbn");
     $book->description = $request->get('description');
     $book->date_published = $request->get('date_published');
     $book->record_id = $book_id;
     $book->save();
     return redirect()->route('books.home')->with('status', "New book created");
 }
开发者ID:jmnerd07,项目名称:book-management,代码行数:59,代码来源:BooksController.php

示例4: actionLogin

 public function actionLogin()
 {
     $user_name = \Yii::$app->request->post()['user_name'];
     $password = \Yii::$app->request->post()['pwd'];
     $author_info = new Author();
     $author_info->name = $user_name;
     $author_info->pwd = $password;
     if ($author_info->save()) {
         $author_id = Author::findBySql("select id from author ORDER BY id DESC LIMIT 0,1")->asArray()->all();
         $array = ['error_no' => 0, 'error_msg' => '', 'data' => $author_id[0]];
         echo json_encode($array);
     }
 }
开发者ID:hanjt,项目名称:synchronizeInfo-server,代码行数:13,代码来源:AuthorController.php

示例5: getRelationships

 /**
  * @inheritdoc
  */
 public function getRelationships($post, array $includeRelationships = [])
 {
     /** @var Post $post */
     // that's an example how $includeRelationships could be used for reducing requests to database
     if (isset($includeRelationships['author']) === true) {
         // as author will be included as full resource we have to give full resource
         $author = $post->author;
     } else {
         // as author will be included as just id and type so it's not necessary to load it from database
         $author = new Author();
         $author->setAttribute($author->getKeyName(), $post->author_id);
     }
     return ['author' => [self::DATA => $author], 'comments' => [self::DATA => $post->comments->all()]];
 }
开发者ID:greyexpert,项目名称:limoncello-shot,代码行数:17,代码来源:PostSchema.php

示例6: actionShow

 /**
  * Показывает контент
  * @return string
  * @TODO Нужно предусмотреть возможность вывода разного контента, привязаного к одной категории
  *
  */
 public function actionShow()
 {
     $this->cat_id = Yii::$app->getRequest()->getQueryParam('id') ? Yii::$app->getRequest()->getQueryParam('id') : null;
     $cat_obg = Categories::find()->where('id = ' . $this->cat_id)->one();
     $allContent = Articles::find()->where('cat_id = ' . $this->cat_id)->all();
     $allArticlesForPager = Articles::find()->where(['cat_id' => $this->cat_id]);
     $countQueryCont = clone $allArticlesForPager;
     $pagesGlobal = new Pagination(['totalCount' => $countQueryCont->count(), 'pageSize' => 1, 'forcePageParam' => false, 'pageSizeParam' => false]);
     $artPages = $allArticlesForPager->offset($pagesGlobal->offset)->limit($pagesGlobal->limit)->all();
     foreach ($allContent as $article) {
         //var_dump($this->cat_id);
         $this->article_id = $article->id;
         $article = Articles::findOne($this->article_id);
         $allArticles = ArticlesContent::find()->where(['articles_id' => $this->article_id])->orderBy(['id' => SORT_DESC]);
         //var_dump($allArticles); exit;
         $countQuery = clone $allArticles;
         $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => isset($article->onepages) ? $article->onepages : 0, 'forcePageParam' => false, 'pageSizeParam' => false]);
         $models = $allArticles->offset($pages->offset)->limit($pages->limit)->all();
         $this->source = Source::find()->where(['id' => $models[0]->source_id])->one()->title;
         $this->author = Author::find()->where(['id' => Source::find()->where(['id' => $models[0]->source_id])->one()->author_id])->one()->name;
         $this->articles[] = ['article' => $article, 'contents' => $models, 'pages' => $pages, 'source' => $this->source, 'author' => $this->author];
     }
     //var_dump($this->articles); exit;
     return $this->renderPartial($cat_obg->action, ['articles' => $this->articles, 'cat' => $this->cat_id, 'pagesGlobal' => $pagesGlobal, 'artPages' => $artPages, 'cat_obg' => $cat_obg]);
 }
开发者ID:roman1970,项目名称:lis,代码行数:31,代码来源:DefaultController.php

示例7: actionCreate

 /**
  * Создание автораа
  * @return string
  */
 public function actionCreate()
 {
     $model = new Author();
     if ($model->load(Yii::$app->request->post())) {
         $model->name = Yii::$app->request->post('Author')['name'];
         $model->status = Yii::$app->request->post('Author')['status'];
         $model->description = Yii::$app->request->post('Author')['description'];
         $model->country_id = Yii::$app->request->post('Author')['country_id'];
         $model->save(false);
         $authors = Author::find();
         $dataProvider = new ActiveDataProvider(['query' => $authors]);
         return $this->redirect(Url::toRoute('author/index'));
     } else {
         return $this->render('_form', ['model' => $model]);
     }
 }
开发者ID:roman1970,项目名称:lis,代码行数:20,代码来源:AuthorController.php

示例8: __get

 /**
  * @param $name
  * @return Author
  */
 public function __get($name)
 {
     if ('author' === $name && null !== $this->author_id) {
         return Author::findByID($this->author_id);
     }
     return false;
 }
开发者ID:scorp7mix,项目名称:pr-of-it.php2,代码行数:11,代码来源:News.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     foreach (range(1, 100) as $index) {
         DB::table('books')->insert(['title' => $faker->word(), 'preview' => $faker->sentence(), 'author_id' => \App\Models\Author::orderByRaw("RAND()")->first()->id, 'created_at' => Carbon\Carbon::now(), 'updated_at' => Carbon\Carbon::now()]);
     }
 }
开发者ID:Gurzhii,项目名称:laravel-jsonapi-example,代码行数:12,代码来源:BooksTableSeeder.php

示例10: search

 public function search($params)
 {
     $query = Author::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
开发者ID:roman1970,项目名称:lis,代码行数:8,代码来源:AuthorSearch.php

示例11: getAuthor

 public function getAuthor()
 {
     if (!empty($this->data['author_id'])) {
         return Author::findOneById($this->data['author_id']);
     } else {
         return false;
     }
 }
开发者ID:RayManOff,项目名称:my-blog,代码行数:8,代码来源:News.php

示例12: testModelSeed

 /**
  * Test samples for all models have been seeded.
  */
 public function testModelSeed()
 {
     $message = 'Haven\'t you forgotten to run artisan migrate and db::seed?';
     $this->assertNotEmpty(Author::all(), $message);
     $this->assertNotEmpty(Comment::all(), $message);
     $this->assertNotEmpty(Post::all(), $message);
     $this->assertNotEmpty(Site::all(), $message);
 }
开发者ID:jonpitch,项目名称:limoncello-collins,代码行数:11,代码来源:ModelsAndSeedsTest.php

示例13: actionIndex

 /**
  * @param string $q
  * @return array
  */
 public function actionIndex($q = null)
 {
     Yii::$app->getResponse()->format = Response::FORMAT_JSON;
     $model = Author::find()->limit(10);
     if (!is_null($q)) {
         $model->where(['or', ['like', 'firstname', $q], ['like', 'lastname', $q]]);
     }
     return ['results' => $model->all()];
 }
开发者ID:MaxHero,项目名称:yii2-books,代码行数:13,代码来源:AuthorController.php

示例14: actionDelete

 /**
  * Удаление автора.
  *
  * @param int $id
  * @return \yii\web\Response
  */
 public function actionDelete($id)
 {
     /** @var Author $modelAuthor */
     $modelAuthor = Author::findOne($id);
     if ($modelAuthor->delete()) {
         return $this->redirect(['back-author/index']);
     }
     return $this->refresh();
 }
开发者ID:Rey8d01,项目名称:book-catalog,代码行数:15,代码来源:BackAuthorController.php

示例15: actionUpdate

 /**
  * Updates an existing Book model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $authors = \app\models\Author::find()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('update', ['model' => $model, 'authors' => $authors]);
     }
 }
开发者ID:jerichozis,项目名称:books,代码行数:16,代码来源:BookController.php


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