file_get_contents('http://example.com');
$org = OrgModel::all();
foreach ($org as $item) {
$item->user();
}
$org = OrgModel::with('user')->all();
foreach ($org as $item) {
var_dump($item->user);
}
$app = new Illuminate\Container\Container();
$app->bind('app', $app);
$app->instance('log', $log);
$app->bind('MongoLog', 'log');
class A extends SplObjectStorage
{
protected $log;
public function __construct(MongoLog $log)
{
$this->log = $log;
}
}
class B extends A {}
class C extends A {}
$a = $app->make('A');
$b = $app->make('B');
$c = $app->make('C');
public function save(array $options = array()) {
return parent::save($options);
}
app/storage/logs/laravel.log
и выложите сюда последние строки из него English (en)
Russian (ru)
Ukrainian (uk)
Dutch (nl)
Spanish (es)
Portuguese (pt)
<?php
use Illuminate\Support\ServiceProvider;
class MyServiceProvider extends ServiceProvider
{
public function boot()
{
//
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
// Вешаем на роуты
Route::when('*' , function ()
{
View::share('title', 'Дефолтный заголовок');
});
// или вот так на определенный шаблон
View::composer(['layout.main', 'layout.page', /* ... */] , function ($view)
{
$view->with('title', 'Дефолтный заголовок');
});
}
}
'providers' => [
/* ... */
'MyServiceProvider',
/* ... */
],
"autoload": {
"classmap": [
"app/services"
]
}
<?php
class MySuperModel extends Eloquent
{
public function mySuperFunction($param1 = null, $param2 = null)
{
return [$param1, $param2, $this->id];
}
}
$model = MySuperModel::find(1); // 1 это ID модели в базе
$result = $model->mySuperFunction(100, 200);
print_r($result);
/*
Array
(
[0] => 100
[1] => 200
[2] => 1 // ID модели $this->id
)
*/