Skip to content

Instantly share code, notes, and snippets.

View aavrug's full-sized avatar
🏃‍♂️
Focusing

Gaurav Kumar aavrug

🏃‍♂️
Focusing
View GitHub Profile
<?php
use Phinx\Migration\AbstractMigration;
class CreatePagesTable extends AbstractMigration
{
// public function change()
// {
// }
public function add() {
$post = $this->Posts->newEntity($this->request->data, ['associated' => ['Categories' => ['validate' => 'notEmpty']]]);
if ($this->request->is('post')) {
$newData = ['user_id' => $this->Auth->user('id')];
// $this->request->data['user_id'] = $this->Auth->user('id');
$post = $this->Posts->patchEntity($post, $newData);
// $post->user_id = $this->Auth->user('id');
// debug($post);exit;
if ($this->Posts->save($post)) {
<!-- File: src/Template/Users/add.ctp -->
<h1>Add a new User</h1>
<?php
echo $this->Form->create($user, ['type' => 'file']);
echo $this->Form->input('username');
echo $this->Form->input('password');
echo $this->Form->input('date_of_birth', [
'label' => 'Date of birth',
'minYear' => date('Y') - 70,
echo $this->Form->create($user, ['type' => 'file']);
echo $this->Form->input($user, ['type' => 'file']);
echo $this->Form->input('profile_image', ['type' => 'file']);
echo $this->Form->button(__('Register'));
echo $this->Form->end();
Fatal error: Class 'Proffer\Database\Type\FileType' not found in /home/gaurav/public_html/Cake3/Chitchat/vendor/cakephp/cakephp/src/Database/Type.php on line 105 Call Stack: 0.0001 124860 1.
public function up()
{
Schema::create('articles', function(Blueprint $table)
{
$table->increments('id');
$table->string('title');
$table->text('body');
$table->timestamps('published_at');
$table->timestamps();
});
<td>{!! link_to_action('PostsController@edit', 'Edit Post', $parameters = array($post->id), $attributes = ['class' => 'btn btn-warning']) !!} {!! link_to_action('PostsController@destroy', 'Delete', $parameters = array($post->id), $attributes = ['class' => 'btn btn-danger']) !!}</td>
//routes.php
Route::resource('posts', 'PostsController');
//controller
public function show($id)
{
$post = Post::findOrFail($id);
return view('posts.show', compact('post'));
<table class="table table-bordered table-striped table-hover">
<tr>
<th>Title</th>
<th>Description</th>
<th>Published on</th>
<th>Action</th>
</tr>
<tr>
<td><a href="http://localhost:8080/posts/10">Kuchi ku</a></td>
<td>Kuchi ku Kuchi kuKuchi ku Kuchi kuKuchi kuKuchi kuKuchi kuKuchi kuKuchi kuKuchi ku</td>
@aavrug
aavrug / gist:4a9330c28a1f01bdb524
Created June 10, 2015 07:05
index of postcontroller in Laravel5
@extends('app')
@section('content')
{!! link_to('posts/create', 'Add Post', ['class' => 'btn btn-primary']) !!}
@if ($posts)
<hr/>
<table class="table table-bordered table-striped table-hover">
<tr>
<th>Title</th>