本文整理汇总了PHP中Portfolio::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Portfolio::find方法的具体用法?PHP Portfolio::find怎么用?PHP Portfolio::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfolio
的用法示例。
在下文中一共展示了Portfolio::find方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editar
public static function editar($input)
{
$respuesta = array();
$reglas = array();
if (isset($input['imagen_portada_crop'])) {
$reglas['imagen_portada_crop'] = array('required');
}
$validator = Validator::make($input, $reglas);
if ($validator->fails()) {
$messages = $validator->messages();
if ($messages->has('titulo')) {
$respuesta['mensaje'] = $messages->first('titulo');
} elseif ($messages->has('imagen_portada_crop')) {
$respuesta['mensaje'] = 'Se olvidó de guardar la imagen recortada.';
} else {
$respuesta['mensaje'] = 'Los datos necesarios para la obra son erróneos.';
}
$respuesta['error'] = true;
} else {
$portfolio_simple = Portfolio::find($input['portfolio_id']);
$portfolio_simple->save();
if (isset($input['descripcion'])) {
$input['descripcion'] = $input['descripcion'];
} else {
$input['descripcion'] = NULL;
}
$item = Item::editarItem($input);
$respuesta['mensaje'] = 'Obra modificada.';
$respuesta['error'] = false;
$respuesta['data'] = $portfolio_simple;
}
return $respuesta;
}
示例2: testDeleteHabtmReferenceWithConditions
/**
* testDeleteHabtmReferenceWithConditions method
*
* @return void
*/
public function testDeleteHabtmReferenceWithConditions()
{
$this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image');
$Portfolio = new Portfolio();
$Portfolio->hasAndBelongsToMany['Item']['conditions'] = array('ItemsPortfolio.item_id >' => 1);
$result = $Portfolio->find('first', array('conditions' => array('Portfolio.id' => 1)));
$expected = array(array('id' => 3, 'syfile_id' => 3, 'published' => false, 'name' => 'Item 3', 'ItemsPortfolio' => array('id' => 3, 'item_id' => 3, 'portfolio_id' => 1)), array('id' => 4, 'syfile_id' => 4, 'published' => false, 'name' => 'Item 4', 'ItemsPortfolio' => array('id' => 4, 'item_id' => 4, 'portfolio_id' => 1)), array('id' => 5, 'syfile_id' => 5, 'published' => false, 'name' => 'Item 5', 'ItemsPortfolio' => array('id' => 5, 'item_id' => 5, 'portfolio_id' => 1)));
$this->assertEquals($expected, $result['Item']);
$result = $Portfolio->ItemsPortfolio->find('all', array('conditions' => array('ItemsPortfolio.portfolio_id' => 1)));
$expected = array(array('ItemsPortfolio' => array('id' => 1, 'item_id' => 1, 'portfolio_id' => 1)), array('ItemsPortfolio' => array('id' => 3, 'item_id' => 3, 'portfolio_id' => 1)), array('ItemsPortfolio' => array('id' => 4, 'item_id' => 4, 'portfolio_id' => 1)), array('ItemsPortfolio' => array('id' => 5, 'item_id' => 5, 'portfolio_id' => 1)));
$this->assertEquals($expected, $result);
$Portfolio->delete(1);
$result = $Portfolio->find('first', array('conditions' => array('Portfolio.id' => 1)));
$this->assertFalse($result);
$result = $Portfolio->ItemsPortfolio->find('all', array('conditions' => array('ItemsPortfolio.portfolio_id' => 1)));
$this->assertEquals(array(), $result);
}
示例3: vistaEditar
public function vistaEditar($id, $next, $seccion_next)
{
//Me quedo con el item, buscando por id
$item = Item::find($id);
$portfolio = Portfolio::find($item->portfolio()->id);
$secciones = parent::seccionesDinamicas();
if ($portfolio) {
$this->array_view['item'] = $portfolio->item();
$this->array_view['portfolio'] = $portfolio;
$this->array_view['secciones'] = $secciones;
$this->array_view['continue'] = $next;
$this->array_view['seccion_next'] = $seccion_next;
return View::make($this->folder_name . '.editar', $this->array_view);
} else {
$this->array_view['texto'] = Lang::get('controllers.error_carga_pagina');
return View::make($this->project_name . '-error', $this->array_view);
}
}
示例4: searchAction
/**
* Searches for portfolio
*/
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Portfolio", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "id";
$portfolio = Portfolio::find($parameters);
if (count($portfolio) == 0) {
$this->flash->notice("The search did not find any portfolio");
return $this->dispatcher->forward(array("controller" => "portfolio", "action" => "index"));
}
$paginator = new Paginator(array("data" => $portfolio, "limit" => 10, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
示例5: testHabtmRecursiveBelongsTo
/**
* testHabtmRecursiveBelongsTo method
*
* @return void
*/
public function testHabtmRecursiveBelongsTo()
{
$this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image');
$Portfolio = new Portfolio();
$result = $Portfolio->find('first', array('conditions' => array('id' => 2), 'recursive' => 3));
$expected = array('Portfolio' => array('id' => 2, 'seller_id' => 1, 'name' => 'Portfolio 2'), 'Item' => array(array('id' => 2, 'syfile_id' => 2, 'published' => false, 'name' => 'Item 2', 'ItemsPortfolio' => array('id' => 2, 'item_id' => 2, 'portfolio_id' => 2), 'Syfile' => array('id' => 2, 'image_id' => 2, 'name' => 'Syfile 2', 'item_count' => null, 'Image' => array('id' => 2, 'name' => 'Image 2'))), array('id' => 6, 'syfile_id' => 6, 'published' => false, 'name' => 'Item 6', 'ItemsPortfolio' => array('id' => 6, 'item_id' => 6, 'portfolio_id' => 2), 'Syfile' => array('id' => 6, 'image_id' => null, 'name' => 'Syfile 6', 'item_count' => null, 'Image' => array()))));
$this->assertEquals($expected, $result);
}
示例6: delete
/**
* @desc: removes a <em>portfolio</em>
*/
public function delete()
{
try {
$portfolio = Portfolio::find($this->request->getParameter('id'));
if ($portfolio->delete() === FALSE) {
$this->flash('error', 'Cannot delete <em>' . $portfolio->name . '</em>!');
return $this->redirect_to('index');
}
$this->flash('notice', '<em>' . $portfolio->name . '</em> succesfully removed');
$this->redirect_to('index');
} catch (ActiveRecordException $arEx) {
$this->flash('error', $arEx->getMessage());
$this->redirect_to('index');
}
}
示例7: delete
public function delete($id)
{
$table = Portfolio::find($id);
if ($table->delete()) {
$name = trans("name.{$this->name}");
return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
}
return Redirect::to("admin/{$this->name}")->with('error', Lang::get('message.error'));
}
示例8: indexAction
public function indexAction()
{
$this->view->portfolio = Portfolio::find();
$this->tag->setTitle('Noud Roosendaal');
}
示例9: portfolio_simple
public function portfolio_simple()
{
return Portfolio::find($this->portfolio_simple_id);
}
示例10: edit
/**
* Show the form for editing the specified portfolio.
*
* @param int $id
* @return Response
*/
public function edit($id = NULL)
{
parent::show();
$portfolio = Portfolio::find($id);
return View::make('portfolios.edit', compact('portfolio'));
}
示例11: getDelete
public function getDelete($id)
{
// Find the portfolio using the user id
$portfolio = Portfolio::find($id);
if ($portfolio == null) {
$errors = new \Illuminate\Support\MessageBag();
$errors->add('deleteError', "The data cannot be deleted at this time.");
return \Redirect::to('/admin/portfolios')->withErrors($errors);
}
// Delete all images first
$portfolio->deleteAllImages();
// Delete image folder if still exist
$img_folder = \Config::get('redminportal::image.upload_path') . "/portfolios/" . $id;
$portfolio->deleteImageFolder($img_folder);
// Delete the portfolio
$portfolio->delete();
return \Redirect::to('admin/portfolios');
}