示例#1
0
<?php

#1. LOGIC
Auth::kickout('/pokecart/');
$comment = new Comment();
$comment->load(Route::param('id'));
if ($comment->user_id == Auth::user_id()) {
    if (Input::posted()) {
        $comment->content = Input::get('message');
        $comment->save();
        URL::restore();
    }
}
Sticky::set('message', $comment->content);
#2. LOAD VIEWS
include VIEWS . 'header.php';
include VIEWS . 'edit_comment.php';
include VIEWS . 'footer.php';
示例#2
0
<?php

# controllers/editbill.php
# Logic
Auth::kickout_non_admin('/');
$bill = new Bill();
$bill->load(Route::param('id'));
if (Input::posted()) {
    $bill->fill(Input::all());
    $bill->splitcost = round($bill->cost / 5, 2, PHP_ROUND_HALF_UP);
    if ($_FILES) {
        $files = Upload::to_folder('assets/uploads/');
        if ($files[0]['error_message'] == false) {
            $bill->image = $files[0]['filepath'];
        }
    }
    $bill->save();
    URL::redirect('/admin');
}
Sticky::set('category', $bill->category);
Sticky::set('cost', $bill->cost);
Sticky::set('notes', $bill->notes);
$title = 'Edit Bill';
# Views
include VIEWS . 'header.php';
include VIEWS . 'bill_form.php';
include VIEWS . 'footer.php';
<?php

# edit_task.php
# 1. Logic
$projects = new Projects_Collection();
$projects->where(['deleted' => '0']);
$projects->where(['user_id' => AUTH::user_id()]);
$projects->get();
$project = new Project();
$project->load(['slug' => Route::param('slug')]);
if (Input::posted()) {
    $project->fill(Input::all());
    $project->save();
    URL::redirect('/' . $project->slug);
}
Sticky::set('project_name', $project->project_name);
Sticky::set('project_description', $project->project_description);
Sticky::set('deadline', $project->deadline);
$title = 'Edit Project';
#2. Views
include VIEWS . 'header.php';
include VIEWS . 'new_project.php';
include VIEWS . 'footer.php';
示例#4
0
<?php

# edit_task.php
# 1. Logic
$task = new Task();
$task->load(Route::param('id'));
$project = new Project();
$project->load($task->project_id);
if (Input::posted()) {
    $task->fill(Input::all());
    $task->save();
    URL::redirect('/' . $project->slug);
}
Sticky::set('name', $task->name);
Sticky::set('description', $task->description);