Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 17:09
    egyjs opened #118
  • 17:07
    welcome[bot] commented #117
  • 17:07
    egyjs opened #117
  • 14:57
    enefeka commented #2761
  • 12:23
    pxpm commented #2761
  • 11:23
    enefeka commented #2761
  • 10:24
    pxpm commented #3838
  • 10:08
    pxpm commented #3839
  • Sep 22 21:48
    promatik commented #2752
  • Sep 22 21:48
    promatik commented #2752
  • Sep 22 17:48
    egyjs commented #2752
  • Sep 22 15:42
    welcome[bot] commented #3839
  • Sep 22 15:42
    egyjs labeled #3839
  • Sep 22 15:42
    egyjs opened #3839
  • Sep 22 12:57
    promatik commented #3791
  • Sep 22 10:56
    tabacitu commented #3838
  • Sep 22 10:50
    pxpm commented #3838
  • Sep 22 10:05
    pxpm assigned #3838
  • Sep 22 08:33
    tabacitu commented #118
  • Sep 22 08:32

    tabacitu on 3.0.12

    (compare)

Dimitar Topalov
@o15a3d4l11s2
Another approach would be to generate a temporary .blade.php file out of the database string and use it instead.
HmInt0101
@HmInt0101
Hi @o15a3d4l11s2 , as you said to generate the temporary.blade.php fiel then how can i append the DB template on that temporary balde.
Dimitar Topalov
@o15a3d4l11s2

Since it will be an email and not one-time thing, when I think about it again, you’d better re-generate the blade file when the admin changes the template. But anyways, here’s what I would do in this case:

  1. An email is going to be sent
  2. Read the template from the database
  3. Write a file in a special directory that is accessible for blade (you would nee to add a new path to config/views.php paths to this special directory.
  4. In the email use the newly generated blade file’s name as a template for the email.
    You could name the files something like “mail_template_1234.blade.php” where 1234 is the id of the record that contains the specific template.
    As a next step, as I mentioned, I would do so that the template is not generated on every email sending, but only once, when the admin saves(updates) the template in the database.

Hint: I have not done this myself, so there could be problems on the way.

I know the package has not been updated recently, but you could you some ideas from https://github.com/TerrePorter/StringBladeCompiler
Roger Champagne
@rchampagneca

Hello. Is is possible that Validation Form Requests do not display errors messages below a field whenever a field wrapper is used ?

   $this->crud->addField([
            'name' => 'VHC',
            'label' => 'Hépatite C<br />(anticorps anti-VHC)',
            'type' => 'select_from_array',
            'options' => dropdown_key_list(config('constants.dict_VHC')),
            'default' => 'Null',
            'allows_null' => 'True',
            'wrapper' => [ 'class' => 'col-sm-3 mb-4', 'id' => 'VHC'],
            'tab'  => 'Personne source'
        ]);

Because, if I remove the class from the wrapper above, error messages are displayed as expected.
```
$rules['VHC'] = 'required_if:PersonneSource,Personne source connue' ;

1 reply
Judah Wright
@judahnator:matrix.org
[m]
Hello! I am trying to get some data added to a pivot table and am having some trouble.
I currently have it set up where I have a "fake" repeatable field that has a select->relation and the other pivot data, then in the controller I overwrite the store method to sync the relations and pivot data. This works great for creating new records.
My problem is with editing existing records. Since the \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation sets up the fields before the model is bound to $this->data['entry'] - the only way I have to properly fill that data is to add an accessor to the model.
This feels a bit messy, and I am wondering if there is a better way?
Dimitar Topalov
@o15a3d4l11s2

@judahnator:matrix.org, at the moment I cannot think of another way of implementing it. The repeatable field’s default logic is to store the data as json, so you have to roll your own implementation if you want it a different way.

Regarding the implementation - I could not understand the exact issue. If you do not want to use accessor, you could set the value of the field manually.

1 reply
Pedro Martins
@pxpm
There is the option to use the branch Laravel-Backpack/CRUD#3410 that supports pivot inserting directly from backpack code without need to overwrite anything. Its an experimental branch but alot of people is using it. We keep it in sync with master, so it should be fine to use it.
2 replies
Pedro Martins
@pxpm
Hello @rchampagneca . Please add the default form-group class to the field. Or any other default classes you see in field.
1 reply
@HmInt0101 just use %placeholders% in your email template, and overwrite them before sending the email with correct information
@WelaurS use entity => false to prevent backpack default behaviour
Guillermo Baron
@guillorrr
Hi! I'm trying to modify the text of a button, but it doesn't work
$this->crud->modifyButton("show", [ 'label' => 'Calendar', 'icon' => 'la-calendar' ]);
Judah Wright
@judahnator:matrix.org
[m]
Need to get it merged with master :D
Pedro Martins
@pxpm
Hey @judahnator:matrix.org . We plan to. Fortunately people using it have been reporting bugs, and since is such a big change we hope to merge it without bugs, atleast the known ones. We had the compromise to keep that branch even with master, so you can safely do it, i think.
Mauro Miotello
@blondie63
Hi, i'm new here.. looking https://backpackforlaravel.com/docs/4.1/getting-started-videos#the-admin-interface-1 video i see two strange thing:
  1. author use "newdb command" , where is it ?
  2. author does not serve application before he open browser "http://project.test" , how is possible ?
    Thanks for clarifications
Cristian Tabacitu
@tabacitu
@blondie63 indeed, the newdb command is something only on my computer, you won't have that command. I mention in that video that it's a "shorthand", as I mistakenly call it 😅 I didn't think it's worth taking the time to explain how to create a database, nor how to serve the Laravel app. That's because Backpack really isn't geared towards first-time Laravel developers. Trying to teach you both Laravel and Backpack at the same time... it would take so much more time. When you install Backpack, we assume you already know and like Laravel, I'm afraid... We've considered creating a pre-Backpack course, explaining only Laravel, but at the end of the day... there are many people who have already done that, much better than we can. Check out https://laracasts.com/series/laravel-8-from-scratch - Jeffrey Way is the reason I got into the Laravel ecosystem, he's a great teacher.
1 reply
Roger Champagne
@rchampagneca

Fake fields

Trying to setup a couple of fake fields as follows:
1) Model

``` 
protected $fakeColumns =
[
    'Résultats_0',
    'Résultats_1',
    'Résultats_2',
    'Résultats_3'
];

protected $casts =
[
    'Résultats_0' => 'array',
    'Résultats_1' => 'array',
    'Résultats_2' => 'array',
    'Résultats_3' => 'array',
];
``` 

These fields are also fillable.
2) Added field to CRUD controller as follows:

``` 
    $this->crud->addField([
        'name' => 'VHB',
        'type' => 'select_from_array',
        'fake' => true,
        'label' => 'VHB',
        'options' => dropdown_key_list(config('constants.dict_VIH')),
        'store_in' => 'Résultats_0'
    ]);
``` 

The field isn't rendered.

6 replies
qontori
@qontori

Hi there

I am trying to understand how to manage session parameters/variables. I need to set some session parameters/variables when my different admins login, for example their default office (certain admin can only see their office data so I use where clauses in the list operations)

I have inserted this code into dashboardcontroller.php
$user = backpack_user()->id;
$userDefaultCenter = UserCentre::where(['user_id' => $user, 'default' => 1])->first();
$request->session()->put('centre_id', $userDefaultCenter->centre_id);

which works fine if they login and are taken to the dashboard. However when their session times out and they log back in, the last presented page is shown upon login and the above code is not executed. Thus they need to go to the dashboard to have the settings loaded

So
a) I can always redirect them to the dashboard
b) I execute the code upon login no matter where they are

Question
Where should I be coding this so that it is executed nomatter which page is being loaded first ie without forcing to the dashboard.

Thanks in advance for your help

7 replies
Noah Gillard
@NoahNxT

Is there a possibility to detect in a validation request if it is a updateRequest or Storerequest?

example
public function rules()
{
if(UpdateRequest){
specific set of rules
}

if (StoreRequest){
Other set of rules
}
}

1 reply
Guillermo Baron
@guillorrr
Hi! Is it possible to use the upload field with polymorphic relationships?
Guillermo Baron
@guillorrr

My db migrate:

        Schema::create('files', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->longtext('filenames');
            $table->morphs('fileable');
            $table->timestamps();
            $table->softDeletes();
        });

My files Model:

class Files extends Model
{
    use CrudTrait;

    public function fileable()
    {
        return $this->morphTo();
    }
}

My feedback Model

class Feedback extends Model
{
    use CrudTrait;

    protected $table = 'feedbacks';
    protected $casts = [
        'files' => 'array'
    ];

    public function files()
    {
        return $this->morphOne(Files::class, 'fileable');
    }

    public function setFilesAttribute($value)
    {
        $attribute_name   = "files";
        $disk             = "public";
        $destination_path = "uploads/feedbacks";
        $this->uploadMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
    }
}

My feedback crud controller field:

        CRUD::addField([
            'name'      => 'files',
            'label'     => 'Files',
            'type'      => 'upload_multiple',

            'upload'    => true,
            'morph'     => true,

            'entity'    => 'files',
            'attribute' => 'filenames',
            'model'     => Files::class,

        ]);

But this give my an error:

BadMethodCallException
Call to undefined method Illuminate\Database\Eloquent\Relations\MorphOne::sync()

Can anybody help me with this? Thanks

HmInt0101
@HmInt0101
Hi @pxpm ,
In my backpack, i have to manually include the "public" folder in files how can i get over to it?
11 replies
HmInt0101
@HmInt0101
AdminDatatables.PNG
@o15a3d4l11s2, This is how it is coming, main pages are working but data tables and fields doesn't.
HmInt0101
@HmInt0101
Hi @o15a3d4l11s2,
I have bcrypt($request->current), and checking against the db->passwword it is not verifying it in the Hash::check($request->current, $db->pwd).
How to resolve this.
4 replies
Panagiotis Saridis
@xPek20_twitter
Hello Guys,
How is it possible to create a non-crud page (e.x seperate page for charts, not dashboard widgets) with the same look as the crud pages. I'm really struggling to make it work. Can anyone help me out?
Pedro Martins
@pxpm
@xPek20_twitter just create a new blade file and the routes that point to it. In the blade file use @extends(backpack_view('blank')) and add your page content inside @section('content') your content here @endsection. Have a look in dashboard file in demo: https://github.com/Laravel-Backpack/demo/blob/master/resources/views/vendor/backpack/base/dashboard.blade.php
Noah Gillard
@NoahNxT

Hi! I've been struggling with the multiple file upload lately. I have multiple fields of multi uploads on 1 model. If I debug 1 mutator it doesn't even get in it and I get the error "Array to string conversion". Any help? I've debugged my request and the filebag has the files, so they're coming in my request at least.

THIS IS AN EXAMPLE OF MY CODE:

My field:

            [   // Upload
                'name' => 'medical_screening_files',
                'label' => 'Medische Schifting Documenten',
                'type' => 'upload_multiple',
                'upload' => true,
                'disk' => Storage::disk('medical_screenings'), // if you store files in the /public folder, please omit this; if you store them in /storage or S3, please specify it;
                // optional:
                //'temporary' => 10 // if using a service, such as S3, that requires you to make temporary URLs this will make a URL that is valid for the number of minutes specified
            ],

Filesystems.php

'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],
        'medical_screenings' => [
            'driver' => 'local',
            'root' => storage_path('app/medical_screenings'),
        ],
]

Model cast:

    protected $casts = [
        'medical_screening_files' => 'array',
    ];

Mutator on model:

    public function setMedicalScreeningFilesAttribute($value)
    {
        $attribute_name = "medical_screening_files";
        $disk = "medical_screenings";
        $destination_path = "medical_screenings";

        $this->uploadMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
    }
Pedro Martins
@pxpm
@NoahNxT Storage::disk('medical_screenings') returns a file system instance i think ? You should pass only the disk name.
mike2410
@mike2410
hey there, hope i'm not interrupting. quick question: I have an app with RECIPES which contain INGREDIENTS which are n:n, I'd like to store the respecitve amount of an INGREDIENT according to RECIPE; in other words: I'd expand the pivot table with an "amount"-field which I'd like to be able to edit within the backpack backend. Could you tell me whether I try to achieve is possible with backpack? Cheers :)
Dimitar Topalov
@o15a3d4l11s2
@mike2410, at the moment there is a PR open that will make this work easier: Laravel-Backpack/CRUD#2938
In the meantime it is still possible to store additional pivot information with a little extra work. It very much depends on how you plan to implement the n:n relationship. Most probably you can use repeatable with a select2 + additional text field for the amount.
mike2410
@mike2410
@o15a3d4l11s2 ah i see, will check this out. thanks a lot mate!
Quentin LOZACH
@Astriel
Hello everyone. I was wondering if it was possible to add a Google Recaptcha at the login of the back-office ? And if yes, how can I implement that code ?
Noah Gillard
@NoahNxT

@NoahNxT Storage::disk('medical_screenings') returns a file system instance i think ? You should pass only the disk name.

@pxpm I've tried that, but with no success :/

Pedro Martins
@pxpm
@NoahNxT do you have medical_screening_files in your model $fillable ?
@o15a3d4l11s2 thanks for the help here, but actually the PR is Laravel-Backpack/CRUD#3410
I closed the one you mentioned to don't create confusiion, it's merged on the 3410. I should have closed it earlier!
ping @mike2410 fyi
HmInt0101
@HmInt0101
@pxpm, can you help me with Websocket (client) with PHP server.
I just want the unmask the message sent from the client to the server. locally the unmask is working but it is running on hosted the text is adding some strange chars sented from client to server.
Pedro Martins
@pxpm
probably something to do with enconding on your server. ask google: php websockets encoding and read one or two of the top results, you should be good with it.
HmInt0101
@HmInt0101
Hi @o15a3d4l11s2, How can i allow any IP address in the Fruitcake package without using the " * " in Allowed_origines.
3 replies
Noah Gillard
@NoahNxT

@NoahNxT do you have medical_screening_files in your model $fillable ?

Yes! it is fillable!

1 reply
Quentin LOZACH
@Astriel
Still looking to deploy Google Recaptcha at the login on the BackOffice, but don't know what code to overload to integrate that.
1 reply
Roger Champagne
@rchampagneca
How to I display timestamps (created_at and updated_at) in crud panel ?
3 replies
Panagiotis Saridis
@xPek20_twitter
Why do columns round the decimal that has to be displayed?
Saving a field e.x 21.60, it's displayed as 22 in the crud table even though it's saved as 21.60 in the database
code in controller:
$this->crud->addColumn([ 'name' => 'amount', 'label' => 'Ποσό', 'type' => 'number', 'decimals' => 5 ]);
Panagiotis Saridis
@xPek20_twitter
and the code in the migration:
$table->decimal('amount', 15, 10)->nullable();