/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $input = $request->all(); if ($this->portfolioRepository->create($input)) { return 'sucesso'; } }
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); }
/** @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); }
<?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'; } ?>
/** * @expectedException LogicException */ public function testLoadDuplicate() { PostRepository::load(); }
/** * @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())); }
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; }
<?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');
/** * HOME * Visulizar a view principal da home * * @return Response */ public function index() { $dados = ['portfolios' => $this->portfolioRepository->all()]; return view('home.index', $dados); }
public function testLoaded() { $this->assertGreaterThan(0, PostRepository::count()); $this->assertGreaterThan(0, PageRepository::count()); $this->assertGreaterThan(0, PluginRepository::count()); }
public function testRetrieveEventi() { $repo = new PostRepository($this->pdo); $post = $repo->findLastPost(); $this->assertEquals('Primo post', $post->getTitle()); }
<?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>
<?php include_once '../../globals.php'; $allPosts = PostRepository::FindAll(); $formattedPosts = array(); foreach ($allPosts as $post) { $formattedPosts[] = $post->toArray(); } echo json_encode($formattedPosts);