コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     if ($this->portfolioRepository->create($input)) {
         return 'sucesso';
     }
 }
コード例 #2
0
 public function testAddScopeAndSearch()
 {
     $authorId = 1;
     $postRepo = new PostRepository();
     $posts = $postRepo->scope(function ($query) use($authorId) {
         $query->where('author_id', '=', $authorId);
     })->all();
     $this->assertTrue(count($posts) == $this->postByAuthor);
     $this->assertTrue($posts[0]->author_id == $authorId);
 }
コード例 #3
0
ファイル: NewPostTest.php プロジェクト: kfuchs/cribbb
 /** @test */
 public function should_create_new_post()
 {
     $user = m::mock('Cribbb\\Domain\\Model\\Identity\\User');
     $thread = m::mock('Cribbb\\Domain\\Model\\Discussion\\Thread');
     $post = m::mock('Cribbb\\Domain\\Model\\Discussion\\Post');
     $this->users->shouldReceive('userById')->once()->andReturn($user);
     $this->threads->shouldReceive('threadById')->once()->andReturn($thread);
     $thread->shouldReceive('createNewPost')->once()->andReturn($post);
     $this->posts->shouldReceive('add')->once();
     $post = $this->service->create('7c5e8127-3f77-496c-9bb4-5cb092969d89', 'a3d9e532-0ea8-4572-8e83-119fc49e4c6f', 'Hello World');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\Post', $post);
 }
コード例 #4
0
ファイル: update.php プロジェクト: leloulight/didapi
<?php

include_once '../../globals.php';
$response = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // if form has been posted process data
    $postdata = file_get_contents("php://input");
    $request = json_decode($postdata);
    $request->date = date("Y-m-d H:i:s");
    $request->user_id = $_SESSION['user_id'];
    $post = PostRepository::FindById($request->id);
    $success = $post->Update($request);
    echo $success == true ? 'Votre article a bien été sauvegardé' : 'Il y a eu une erreur lors de la sauvegarde de votre article';
}
?>

コード例 #5
0
 /**
  * @expectedException LogicException
  */
 public function testLoadDuplicate()
 {
     PostRepository::load();
 }
コード例 #6
0
 /**
  * @test
  */
 public function it_can_delete_a_record()
 {
     $created = factory(Post::class)->create();
     $this->posts->delete($created->id);
     $this->assertFalse(in_array($created->id, Post::all()->pluck('id')->toArray()));
 }
コード例 #7
0
 public function __construct($data = array())
 {
     parent::__construct();
     $this->guid = $data->guid;
     $this->pubid = $data->pubid;
     $this->type = $data->type;
     $this->caption = $data->caption;
     $this->content = $data->content;
     $this->comment = $data->comment;
     $this->url = $data->url;
     $this->timestamp = $data->timestamp;
     $this->respost_count = $data->repost_count;
     $this->origin_guid = $data->origin_guid;
     $this->origin_pubid = $data->origin_pubid;
     $this->via_guid = $data->via_guid;
 }
コード例 #8
0
ファイル: detail.php プロジェクト: leloulight/didapi
<?php

include '../../globals.php';
$postId = $_GET['id'];
$post;
if (isset($postId)) {
    $entity = PostRepository::FindById('post', $postId);
    $post = new Post($entity->id, $entity->title, $entity->content, $entity->date, $entity->user_id);
}
echo isset($post) == true ? json_encode($post->toArray()) : json_encode('There was an error while processing the retrieval og this message');
コード例 #9
0
 /**
  * HOME
  * Visulizar a view principal da home
  *
  * @return Response
  */
 public function index()
 {
     $dados = ['portfolios' => $this->portfolioRepository->all()];
     return view('home.index', $dados);
 }
コード例 #10
0
ファイル: PochikaTest.php プロジェクト: a11enwong/pochika
 public function testLoaded()
 {
     $this->assertGreaterThan(0, PostRepository::count());
     $this->assertGreaterThan(0, PageRepository::count());
     $this->assertGreaterThan(0, PluginRepository::count());
 }
コード例 #11
0
 public function testRetrieveEventi()
 {
     $repo = new PostRepository($this->pdo);
     $post = $repo->findLastPost();
     $this->assertEquals('Primo post', $post->getTitle());
 }
コード例 #12
0
ファイル: index.php プロジェクト: GrUSP/php_best_practices
<?php

require_once dirname(__FILE__) . '/../src/PostRepository.php';
?>

<?php 
$pdo = new PDO('mysql:host=localhost;dbname=CIBlog', 'user', 'password');
$pr = new PostRepository($pdo);
$post = $pr->findLastPost();
?>

<html>
  <head>
    <title>CIBlog</title>  
    <link rel="stylesheet" href="./css/main.css" type="text/css" />
  </head>
    <body>
    <div id="main">
        <h1 class="prepend-1">CIBlog</h1>
        <h2>Latest Post</h2>
        <div>
            <h2><?php 
echo $post->getTitle();
?>
</h2>
            <p> <?php 
echo $post->getDescription();
?>
</p>
        </div>
    </div>
コード例 #13
0
ファイル: list.php プロジェクト: leloulight/didapi
<?php

include_once '../../globals.php';
$allPosts = PostRepository::FindAll();
$formattedPosts = array();
foreach ($allPosts as $post) {
    $formattedPosts[] = $post->toArray();
}
echo json_encode($formattedPosts);