public static function mapme($objtype) { if ($objtype == "organisation") { $objs = Organisation::all(); } else { $objs = Project::all(); } if (count($objs)) { foreach ($objs as $obj) { $dum[0] = $obj->{$objtype}; $dum[1] = $obj->latitude; $dum[2] = $obj->longitude; $dum[3] = url('/') . "/" . $objtype . "s/" . $obj->id; if ($objtype == "project") { $dum[4] = url('/') . "/public/images/project.png"; } else { $dum[4] = url('/') . "/public/images/" . $obj->organisationtype . ".png"; } $dum[5] = $obj->description; $fin[] = $dum; } return json_encode($fin); } else { return "No data"; } }
public function feed() { $feed = Feed::make(); // cache the feed for 60 minutes (second parameter is optional) $feed->setCache(0, 'NorthCoastCaresFeed'); // check if there is cached feed and build new only if is not if (!$feed->isCached()) { // creating rss feed with our most recent 20 posts $organisations = Organisation::orderBy('created_at', 'desc')->take(20)->get(); $projects = Project::orderBy('created_at', 'desc')->take(20)->get(); // set your feed's title, description, link, pubdate and language $feed->title = 'North Coast Cares'; $feed->description = 'Community and faith-based organisations working for good on the KZN North Coast'; $feed->logo = 'https://scontent-cdg2-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12144733_644650369011345_1628028338195896677_n.png?oh=8ec9cc8612020671b85bc1fe338c7213&oe=56C020F3'; $feed->link = url('feed'); $feed->setDateFormat('datetime'); // 'datetime', 'timestamp' or 'carbon' $feed->pubdate = date('d-m-Y'); $feed->lang = 'en'; $feed->setShortening(true); // true or false $feed->setTextLimit(400); // maximum length of description text foreach ($organisations as $organisation) { // set item's title, author, url, pubdate, description and content if ($organisation->photo != "") { $fulldescrip = "<img height=\"60\" src=\"" . url($organisation->photo) . "\">" . $organisation->description; } else { $fulldescrip = $organisation->description; } $feed->add("New " . strtoupper($organisation->organisationtype) . ": " . $organisation->organisation, "North Coast Cares", url('/organisations/' . $organisation->id), $organisation->created_at, $fulldescrip, $organisation->description); } foreach ($projects as $project) { // set item's title, author, url, pubdate, description and content if ($project->photo != "") { $fulldescrip = "<img height=\"60\" src=\"" . url($project->photo) . "\">" . $project->description; } else { $fulldescrip = $project->description; } $feed->add("New PROJECT: " . $project->project, "North Coast Cares", url('/projects/' . $project->id), $project->created_at, $fulldescrip, $project->description); } } // first param is the feed format // optional: second param is cache duration (value of 0 turns off caching) // optional: you can set custom cache key with 3rd param as string return $feed->render('atom'); }
/** * Finds the Organisation model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Organisation the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Organisation::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getOrganisation() { return $this->hasOne(Organisation::className(), ['id' => 'organisation_id']); }
?> <div class="event-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Event', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'owner_id', 'value' => function ($data) { return Organisation::findOne($data->owner_id)->name; }], 'name', 'slug', ['attribute' => 'start_time', 'value' => function ($data) { return date('jS F Y', strtotime($data->start_time)); }], ['attribute' => 'end_time', 'value' => function ($data) { return date('jS F Y', strtotime($data->end_time)); }], ['attribute' => 'location_id', 'value' => function ($data) { return Location::findOne($data->location_id)->name; }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
use app\models\Organisation; use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model app\models\Event */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="event-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'owner_id')->dropDownList(Organisation::getList()); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'slug')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'start_time')->input('datetime'); ?> <?php
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $organisation = Organisation::find($id); $organisation->delete(); return redirect()->route('organisations.index')->with('okmessage', 'Organisation has been deleted'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $data['alltags'] = Tag::orderBy('tag')->get(); $data['organisations'] = Organisation::orderBy('organisation')->get(); $data['project'] = Project::find($id); $data['ptags'] = explode(',', $data['project']->tags); $data['latitude'] = $data['project']->latitude; $data['longitude'] = $data['project']->longitude; return view('projects.edit', $data); }