october cms: relations

Resources: https://octobercms.com/docs/database/relations https://octobercms.com/docs/backend/relations Example: This is a (hopefully correct) working example of a 1 to n relation. // product model public $hasMany = [ ‘variants’ => [‘\Acme\Namespace\Variant’], ]; // variant model public $belongsTo = [ ‘product’ => [‘\Acme\Namespace\Product’], ]; public $attachOne = [ ‘my_image’ => [‘System\Models\File’], ]; # variant fields.yaml Read more…

Forms with Laravel 5

Some components have been removed from Laravel core with version 5. For example the Forms & HTML component. Good to see them again here: https://laravelcollective.com Example form: {{ Form::open([‘route’=>’item.store’, ‘class’=>’form-horizontal’]) }} <div class=”form-group”> <label for=”name” class=”col-sm-2 control-label”>Name</label> <div class=”col-sm-10″> {{ Form::text(‘name’, null, [ ‘class’=>’form-control’, ‘id’=>’name’, ]) }} </div> </div> <div class=”form-group”> <label Read more…

Laravel Lumen: NotFoundHttpException after installation

After a fresh installation of Laravel Lumen, I got a NotFoundHttpException for the index route. I copied the .env.example  file to .env  and set up the APP_KEY. But I still got the NotFoundHttpException. After searching the internet for some time I found out these steps: In public/index.php change the last line to this: $app->run($app[‘request’]); And to make the Read more…

File upload by ajax with Laravel and jQuery

Some Controller method in Laravel 4.2, with some JSON responses: public function postUpload() { Input::file(‘uploadfile’)->move(storage_path(‘temp/’), ‘import.xls’); try { Artisan::call(‘importexcelfile’, [ ‘file’ => ‘app/storage/temp/import.xlsm’, ]); return Response::json([ ‘result’ => 1 ]); } catch (Exception $e) { return Response::json([ ‘result’ => -1, ‘message’ => $e->getMessage(), ]); } } Some jQuery code, which handles Read more…

Call an Artisan Command from anywhere

Small note on how to call an Artisan Command from a Controller or somewhere else: # example 1 Artisan::call(‘files:zip’, [ ‘ziparchiv’ => base_path(‘export/archiv.zip’), ‘files’ => base_path(‘export/*.json’) ]); # example 2 Artisan::call(‘files:export’, [ ‘–remove’ => true, ‘path’ => base_path(‘export/’) ]);  

Line breaks in Blade sections and yields

How to avoid line breaks in Laravel blade sections or yields. The problem // the laylout <title>@yield(‘title’)</title> // the child @section(‘title’) title @stop // the result <title>title </title> The solution // the laylout <title>@yield(‘title’)</title> // the child @section(‘title’, ‘title’) // the result <title>title</title> Using @parent or other blade specials: @section(‘title’, Read more…

Laravel: resolve the logged in user from the IoC container

Behind the scenes, the Auth facade is bound to Illuminate\Auth\AuthManager. Means, you need to resolve the AuthManager. This example resolve the currently logged in user from the IoC container: use Illuminate\Auth\AuthManager; class MyController extends \BaseController { protected $user; public function __construct(AuthManager $auth) { $this->user = $auth->user(); } } Link to reference: http://laravel.com/api/4.2/Illuminate/Auth/AuthManager.html

XML Sitemap

A sitemap is a file where you can list the web pages of your site to tell Google and other search engines about the organization of your site content

This is how Google describes a sitemap and it tells you all about its purpose.

When I write custom software, I usually want to create a sitemap with PHP automatically.