What's new

Welcome to xCrud Community - Data Management and extended PHP CRUD

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

xcrud laravel

dhuerta29

Member
Joined
Dec 10, 2021
Messages
30
Reaction score
1
Points
8
Location
chile
i am trying to get the insert callback to work in the same laravel controller but i cant do it this is my code can this be done?

class VehicleRegisterController extends Controller
{
public function index()
{
$xcrud = Xcrud_get_instance();
$xcrud->table("vehicles");
$xcrud->before_insert("insert_payments", route('vehicles'));

function insert_payments($postdata, $xcrud){
$patent = $postdata->get('patent');

}

$render = $xcrud->render();
}
}
 

DaDo

Administrator
Staff member
Joined
Dec 1, 2021
Messages
108
Reaction score
23
Points
18
in your controller VehicleRegisterController.php
PHP:
class VehicleRegisterController extends Controller
{
public function index()
{
$xcrud = Xcrud_get_instance();
$xcrud->table("vehicles");
$xcrud->before_insert("insert_payments", 'function_page.php');



$render = $xcrud->render();
}
}

in xcrud folder create fie function_page.php and add
PHP:
function insert_payments($postdata, $xcrud){
$patent = $postdata->get('patent');
}
 

dhuerta29

Member
Joined
Dec 10, 2021
Messages
30
Reaction score
1
Points
8
Location
chile
I have been a bit busy but here is the explanation you must create a helper, that is, inside the app folder you must create a folder called Helper and inside a file I have put xcrud.php with the following code

<?php
require_once(app_path(). '/xcrud/xcrud.php');
if(!function_exists('Xcrud_get_instance')) {
function Xcrud_get_instance($name = false){
return Xcrud::get_instance($name);
}
}

after this you create a provider in the providers folder in the file called AppServiceProvider.php it should look like this

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
require_once __DIR__ . '/../helpers/xcrud.php';

}

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}

and it would only be enough in the controller or where you want to call it like that

$xcrud = Xcrud_get_instance();
 

FILSILVA81

New member
Joined
Feb 3, 2022
Messages
29
Reaction score
2
Points
3
Location
Portugal
Hello, is there any news about the updates for when it will be ready?
Same question. Sadly since the beginning of this forum I didn't see any information about a schedule for the release. If that could be released and the code shared I'm sure everyone will help to develop new things.
 

Pecky

New member
Joined
Dec 10, 2021
Messages
2
Reaction score
0
Points
1
Location
UK
Thanks for the info dhuerta29. I've got it working in Laravel using your info as a guide.

Only problem I'm having is with the Date field. If I add a new record, the date works as normal by opening the calendar and it saves OK. If I edit a record it doesn't pop the calendar up and even if you manually type a date it just stores a Null value.

I don't suppose you had any issues with date fields?
 

dhuerta29

Member
Joined
Dec 10, 2021
Messages
30
Reaction score
1
Points
8
Location
chile
Thanks for the info dhuerta29. I've got it working in Laravel using your info as a guide.

Only problem I'm having is with the Date field. If I add a new record, the date works as normal by opening the calendar and it saves OK. If I edit a record it doesn't pop the calendar up and even if you manually type a date it just stores a Null value.

I don't suppose you had any issues with date fields?
Hi, I didn't try it with the date field, I stopped using xcrud, now I'm using pdocrud and everything is working perfectly here with the same steps
 
Top Bottom