fuelPHP (9)

fuelphp simpleauth – group or group_id

There’s an error here: /packages/auth/classes/auth/login/simpleauth.php line 257: ‘group_id’ => (int) $group, should actually be: ‘group’ => (int) $group, otherwise you will get an error when generating with Oil.

Setting a default order_by in related models using fuelPHP

Notes on the system i’m building: A user has many sets of related data, one set being a list of quote item rates which get used (to form a dropdown) when a user is creating a quote item, this list of course needs to be ordered correctly, as the user can manage these items, deleting, […]

fuelphp custom configurations

I recently built my client management / quote / invoice system using fuelPHP, and needed to add some defaults settings when a new user registers to use the system. For example, a user signs up, their details are stored in a users table, but users also have settings such as quote item rates (£30, £40, […]

fuelPHP Related Models

Just as a point of reference, nothing here that isn’t in the fuelPHP documentation. Using fuelPHP Related Models. All relationships are declared in the Model of course. Belongs to A quote will belong to a client, and also a user. [code] protected static $_belongs_to = array( ‘user’ => array( ‘key_from’ => ‘user_id’, ‘model_to’ => ‘Model_User’, […]

Pagination in fuelPHP

We always need pagination for displaying many records. fuelPHP makes this easy for us: [code] $countQuotes = count(Model_Quote::query()->where(‘user_id’, Auth::instance()->get(‘id’))->get()); $pagination = Pagination::forge(‘pagedquotes’, array( ‘pagination_url’ => ‘/quotes/’, ‘total_items’ => $countQuotes, ‘per_page’ => 10, ‘uri_segment’ => ‘page’, )); $data[‘quotes’] = Model_Quote::query()->where(‘user_id’, Auth::instance()->get(‘id’))->limit($pagination->per_page)->offset($pagination->offset)->get(); $data[‘pagination’] = $pagination->render(); [/code] And in the View: [code] <table id="quotesTable" class="table table-striped"> <thead> <tr> […]

Build a forgot password system in fuelPHP

I built myself a forgot password system in fuelPHP, and have needed it a few times since, so I thought i would write it here. I needed something like this: User visits /forgot, enters their email address, we check that it exists, if so, generate a unique string and email them. The link should expire […]

Generate PDF with fuelPHP

Generating PDF with fuelPHP is very straight forward using the built in wrappers around TCPDF or DOMPDF (my preferred choice) First things, configure fuel to use pdf To generate a PDF with fuelPHP: [code] $data[‘quote’] = Model_Quote::find($id); $view = View::forge(‘quotes/print’, $data, false); $pdf = Pdf::factory(‘dompdf’)->init(); $pdf->set_paper(‘A4’); $pdf->load_html($view); $pdf->render(); [/code] In View file, in views/quotes/print is […]

Sending Email with fuelPHP

Sending email with fuelPHP is really straight forward, as are most things with fuel! In this example i am sending a quote to a client and attaching a PDF: [code] $email = \Email::forge(); $email->to($data[‘quote’]->client->email, $data[‘quote’]->client->name); $email->subject(‘New Quote from ‘ .$data[‘quote’]->user->username); $email->html_body(\View::forge(’email/quotetoclient’, $data)); $email->from(‘changed-no-spam@stuartsillitoe.co.uk’, ‘Stuart’); $view = View::forge(‘quotes/print’, $data, false); $pdf = Pdf::factory(‘dompdf’)->init(); $pdf->set_paper(‘A4’); $pdf->load_html($view); $pdf->render(); […]

Using OIL in fuelPHP

Using OIL to generate Models, Controllers, Views, or even entire Scaffolding. A few notes. Quickly generate a model for albums: [code] oil generate model albums title:string description:text released:date image:string [/code] A Model for tracks… [code] oil generate model tracks title:string description:text album_id:int [/code] Generate Entire Scaffolding Generate a complete CRUD interface for albums: [code] oil […]