summaryrefslogtreecommitdiffstats
path: root/controllers/ProfilesController.php
blob: 022b54027b2fc0b0a35ac2e59f16660bfd33d0a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

namespace app\controllers;

use app\models\Profile;

class ProfilesController extends \lithium\action\Controller {

	public function index() {
		$profiles = Profile::all();
		return compact('profiles');
	}

	public function view() {
		$profile = Profile::first($this->request->id);
		return compact('profile');
	}

	public function add() {
		$profile = Profile::create();

		if (($this->request->data) && $profile->save($this->request->data)) {
			$this->redirect(array('Profiles::view', 'args' => array($profile->id)));
		}
		return compact('profile');
	}

	public function edit() {
		$profile = Profile::find($this->request->id);

		if (!$profile) {
			$this->redirect('Profiles::index');
		}
		if (($this->request->data) && $profile->save($this->request->data)) {
			$this->redirect(array('Profiles::view', 'args' => array($profile->id)));
		}
		return compact('profile');
	}
}

?>