Благодетель
@vlsoprun, вы выполнили условие: "Набрать 100 кармы.".
С чем и поздравляем =)
SQLSTATE[23502]: Not null violation: 7 ОШИБКА: нулевое значение в столбце "playlist_id" нарушает ограничение NOT NULL
DETAIL: Ошибочная строка содержит (6, null, null, null, null, null, null, 2016-03-01 08:08:29, 2016-03-01 08:08:29). (SQL: insert into "playlists" ("updated_at", "created_at") values (2016-03-01 08:08:29, 2016-03-01 08:08:29) returning "id")
SQL: insert into "playlists" ("updated_at", "created_at") values (2016-03-01 08:08:29, 2016-03-01 08:08:29) returning "id")
protected $appends = ['user_name'];
@Big-Shark ну как-то через бехавиор..
$cat = new Category();
$cat->setName('Movie');
$cat->save();
$art = new Article();
$art->setTitle('Avatar Makes Best Opening Weekend in the History');
$art->setCategory($cat);
$art->setContent('With $232.2 million worldwide total, Avatar had one of the best-opening weekends in the history of cinema.');
$art->save();
категорию сейвает отлично, а вот Article падает потому что не может найти поля title
new DateTime('first day of week');
@Big-Shark
content
article
video
content базовая, там все общее для типов + само поле типа
А в дочерних таблицах только специфичные поля в
article text
video - url
ну я так надеялся что будет работать
{!! App\Blahblah::get() !!}}
будет работать ?
CREATE TABLE `article`
(
`body` VARCHAR(100),
`id` INTEGER NOT NULL,
`title` VARCHAR(100),
`category_id` INTEGER,
PRIMARY KEY (`id`),
INDEX `article_i_916b34` (`category_id`),
CONSTRAINT `article_fk_3e8e68`
FOREIGN KEY (`id`)
REFERENCES `content` (`id`)
ON DELETE CASCADE,
CONSTRAINT `article_fk_904832`
FOREIGN KEY (`category_id`)
REFERENCES `category` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
не, вон на энжиниксе 1,9,5+ есть. всё, что надо, там где listen указать в конце http2
Route::group(['middleware' => 'admin'], function () {
Route::get('/api', function () {
// что тут вставить ?
});
});
имею такой роут он обращается к посреднику admin :
М↓
public function handle($request, Closure $next)
{
if(Auth()->check() && Auth()->user()->type == 'admin'){
dd('it admin');
}
return $next($request);
}
я не могу понять как дальше уйти в контроллер
М↓
. На неё надо нажать, если ты не знал.
'middleware' => 'admin'
ты говоришь фреймворку, что до обработки этого роута запрос надо «пропустить» через мидлварю admin.Route::get('profile', [
'middleware' => 'auth',
'uses' => 'UserController@showProfile'
]);
Route::group(['middleware' => 'admin'], function () {
Route::get('/api', function () {
// тут как я понимаю нужно обратится к контроллеру?
});
});
@AAmirOFF заместо
```function () {
// тут как я понимаю нужно обратится к контроллеру?
}
``
напиши
'uses' => 'UserController@showProfile'`
Route::group(['middleware' => 'auth'], function () {
$d = 'depon.';
Route::get('/depon', ['as' => $d . 'index', 'uses' => 'DeponController@index']);
Route::get('test', function () {
Echo 'Ok!';
});
$d = 'depon.'
Route::group(['middleware' => 'auth'], function () {
$d = 'depon.';
Route::get('/depon', ['as' => $d . 'index', 'uses' => 'DeponController@index']);
Route::post('/depon', ['as' => $d . 'search', 'uses' => 'DeponController@search']);
Route::get('/depon/clear', ['as' => $d . 'cancel', 'uses' => 'DeponController@clear']);
Route::get('/depon/{id}/edit', ['as' => $d . 'edit', 'uses' => 'DeponController@edit']);
Route::post('/depon/{id}/edit', ['as' => $d . 'editpost', 'uses' => 'DeponController@editPost']);
Route::post('/depon/{id}/close', ['as' => $d . 'close', 'uses' => 'DeponController@closeContract']);
Route::get('/depon/settings', ['as' => 'settings.get', 'uses' => 'DeponController@getSettings']);
Route::post('/depon/settings', ['as' => 'settings.post', 'uses' => 'DeponController@postSettings']);
});
Route::group(['middleware' => 'auth', 'prefix' => 'depon', 'as'=> 'depon.'], function () {
Route::group(['middleware' => 'admin'], function () {
Route::get('/api', ['uses' => 'users\UserController@SeyHello']);
});
у меня так отработало
Любитель сладкого
@assurrussa, вы выполнили условие: "Набрать 50 кармы.".
С чем и поздравляем =)
.html
?
Route::post('/depon/settings', 'DeponController@postSettings')->name('settings.post');
Route::group(['prefix' => 'static', 'postfix' => '{ext}']), function() { ... })
->where('ext', '\.(html|htm)');
var self=this
function bind(fn:Function, target:Object) : Function {
return function () {
return fn.apply(target, arguments);
};
}
class Some {
constructor() {
this.some = bind(this.some, this); // bind function
}
some() { console.log(this); }
}
Object.create = function(o) {
function F() {}
F.prototype = o;
return new F(); }
this.some = bind(this.some, this)
такая странная конструкция))
Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
>name('profile'); // что это
Ассоциативный массив — структура данных, в которой можно хранить любые данные в формате
ключ-значение.
var menuSetup = {
width: 300,
height: 200,
title: "Menu"
};
Но это же и класс?
смотрите какая смешная лара
Таблица news_duplicates
не содержит PK в виде какого то одного филда
так вот
есть код в ядре Laravel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php
* Delete a record from the database.
*
* @param mixed $id
* @return int
*/
public function delete($id = null)
{
// If an ID is passed to the method, we will set the where clause to check
// the ID to allow developers to simply and quickly remove a single row
// from their database without manually specifying the where clauses.
if (! is_null($id)) {
$this->where('id', '=', $id);
}
$sql = $this->grammar->compileDelete($this);
return $this->connection->delete($sql, $this->getBindings());
}
смешным тут является кусок $this->where('id', '=', $id);
то есть прям хардкорно в ядре Laravel ставится ограничение на PK - всегда только id
Всем привет. Подскажите как лучше спроектировать.
Нужно определять к какому типу относиться данный урл и вызвать нужный контроллер.
Например: /урл_страницы - может быть товаром, категорией, текстовой страницей и т.д.
Т.е. в урле не будет /product/, /folder/ и т.д.
Сейчас сделано так:
Route::group(['middleware' => ['web']], function () {
Route::any( '{catchall}', 'PageController@identify')->where('catchall', '(.*)');
});
Внутри PageController, после обработки урла вызывается нужный контроллер
action('Controller@method')
Подход очень не нравиться. Как думаете, можно ли это по другому реализовать ?
/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php
код
protected function setKeysForSaveQuery(Builder $query)
{
$query->where($this->getKeyName(), '=', $this->getKeyForSaveQuery());
return $query;
}
означает, что $this->getKeyName()
должен быть обязательно 1 лишь поле. и это применяется во всех запросах.
это норм?
public function changeSum($sum, $id)
{
$this->oracleConnect->beginTransaction();
try {
$sqlQuery = "update mbcont t set t.totalsum = ? where rowid = CHARTOROWID (?)";
$this->oracleConnect->update($sqlQuery, [$sum, $id]);
} catch (Exception $e) {
$this->oracleConnect->rollBack();
throw new ChangeSumDeponException('Not Change Sum Depon!');
}
$this->oracleConnect->commit();
}
https://gist.github.com/greabock/02c13c428304c5ce9ec4
http://laravel.su/docs/5.0/container
https://gist.github.com/greabock/02c13c428304c5ce9ec4
- а тут разве не interface MailerInterface
вместо class MailerInterface
? Class не заимплементится же вроде как. Или я путаю что?
Парни! Подскажите элегантный способ сделать из массива:
array:10 [
"primary" => "#6ca6d9"
"success" => "#479d63"
"info" => "#5bc0de"
"warning" => "#F39124"
"danger" => "#d9695f"
"purple" => "#fd44c7"
"light-blue" => "#00b3ec"
"blue" => "#026d8f"
"green" => "#9ac333"
"red" => "#fe2c78"
]
Массив где ключи и значения будут одинаковыми
array:10 [
"primary" => "primary"
"success" => "success"
"info" => "info"
"warning" => "warning"
// ....
]
->where('pack_quantity', function ($query) {
$query->from('variants as v2')
->selectRaw('max(pack_quantity)')
->whereRaw('product_id = `variants`.product_id')
->where('quantity', '>', 0);
})
есть код который используется в модели и в сервисном классе. Т.е. в scope не завернуть? как бы красиво это упаковать чтобы можно было использовать в нескольких местах?
var WebSocket = require('websocket')
) медленно но верно отжирал память =(