Giter VIP home page Giter VIP logo

docs's Introduction

Backpack for Laravel Documentation

You can find the online version of the Backpack documentation at https://backpackforlaravel.com/docs

How it works

  • we only keep one branch, master; that's the one showing up on https://backpackforlaravel.com/docs
  • for each breaking version of Backpack we keep a separate folder with all the docs for that version
  • inside each version folder there's an index.md file, where we store the sidebar menu for that version
  • inside each version folder there's an introduction.md file, which is the home page for that version

Contribution guidelines

  • pull requests are welcome and appreciated;
  • pull requests should point to the master branch;
  • all links should point to the current version of the documentation page (ex: /docs/{{version}}/installation);
  • all images should be uploaded to https://backpackforlaravel.com/uploads/docs/ and used from there; ask @tabacitu to help upload them;
  • all headings should be prepended by an HTML anchor, with the name of the heading; this way, Algolia can take the user directly to that heading (ex: <a name="what-my-title-says-but-with-dashes"></a>);

docs's People

Contributors

abbyjanke avatar aula2030 avatar christmex avatar danilopolani avatar dividy avatar egyweb-mohamed avatar felixinx avatar flartet avatar guizoxxv avatar imokhles avatar jcastroa87 avatar jnoordsij avatar karandatwani92 avatar marcbrillault avatar maurohmartinez avatar mnigh avatar olipayne avatar patabugen avatar peterhauke avatar polfo avatar promatik avatar pxpm avatar realtebo avatar siberfx avatar tabacitu avatar themagnifico avatar tomsb avatar urlportal avatar yabbou avatar zachweix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docs's Issues

Unclear How to Use Paid License Key

I scoured Google and the docs, and was unable to find where the license key goes. I ended up doing a search on the code base for the 'You're using unlicensed software' string to find the code responsible for the key check, and saw it was a config. Maybe we could make it easier for people to know where the code goes?

It's possible an instruction was sent in an email, but I'm on a team and didn't see the email that may have been sent out.

I was also unable to see instructions by logging into the dashboard; I was only able to find the key and no instruction on how to use it.

It's possible I'm blind but I'm not seeing docs on this 😅

Possible miscommunication in 4.1 Upgrade Guide

Here's what @azaricstefan had to say about it:


Wanted to share these 2 things with you.

Step 9 useful updates:

  1. I noticed that you didn’t take into account table revisions, I fixed that manually by just adding replace in the same migration that you created.
  2. I had BackpackUser before, now I deleted it as per guide but I get errors such as:
    • Call to undefined relationship [roles] on model [App\Models\User].
      Solution for this was to add this to User model:
  • use Spatie\Permission\Traits\HasRoles;
  • use HasRoles;

Maybe it will be useful to update the upgrade guide with these 2 points, if someone else is experiencing same issue as me.


Let's please investigate and see if we need to make changes to our guide or something.

Easily create, share & use third-party field types

For Backpack developers to easily be able to share field types, column types, buttons, it would be great if people could install field types using composer require. So we could:

  • create a package skeleton for people to develop extra fields/columns/buttons

Provide a simple way to use those installed fields/columns/buttons.

This is already possible, but we should:

  • make it easier, using a package skeleton
  • write a tutorial on how to do it
  • provide a place for people to post their packages (maybe with upvote/downvote system, or stars, so that it's not moderated and completely open to everyone)

Better docs on how to create a Backpack addon, using the auto-wiring in the skeleton

So I've created this thing. This addon skeleton should allow backpackers to create add-ons a lot more easily, basically without even thinking about how packages are supposed to work, because if the files are in the correct place, they'll just be loaded by the AddonServiceProvider we're built.

So basically the process would be:

  • code in your own project
  • use laravel-packager to create a new package, and use our skeleton as a template there;
  • move the files into the package;
  • create a Github repo and push the changes;
  • put it up on Packagist;
  • remove it from packages and install it into vendor to make sure it works for others;

But... we should create a more detailed guide.

[Proposal] Flow chart on how a CRUD works

Similar to how CodeIgniter does it, we could create a simple diagram to explain how CRUDs work:

  • route points to controller
  • controller
    • extends CrudController from the package
    • uses traits from the package
    • uses views from the package
    • uses Model
    • might use FormRequests
  • model
    • uses DBMS

In upgrade Guide to 4.0 6.1 should come before 6.0

When upgradingt from 3.6 to 4.0 it's best to do step 6.1 before 6 in the upgrade guide.

This is beacuse 6.1 removes some old parent:: calls which step 6 says you need to change - but you don't actually need to change them (beacuse 6.1 says to remove them).

I can push a pull-request, but I'm not sure about changing the numbering. If you're OK with me making the removal of public function store(StoreRequest $request) etc step 6.0 and the removal of return parent::show(); etc step 6.1 then I'll make a pull request.

Stop asking me to login, or keep me logged in longer.

Figuratively speaking, "every time" I open a browser to review the documentation I'm assaulted with a fullscreen modal encouraging me to login. Which is annoying on the face of it. Worse is that when I do log in the session doesn't seem to stick around very long so when I come back later that day I'm asked to log in again. Makes the documentation very frustrating to pull up.

(Really loving Backpack so far and I'll grant this is a minor issue but it's just driving me 🥜)

Upgrade Guide never says to re-run `php artisan backpack:install`

After upgradig from 3.8 I'm missing a couple of files - BackpackUser.php and CheckIfAdmin.php specifically.

Running :install seems to fix it by putting the missing files in place.

However the upgrade guide never mentions to re-run php artisan backpack:install except if if using elFinder.

Should it mention it somewhere? (if so, where?).

backpack:crud is not a command

I have installed Backpack 4.0.23 and run php artisan backpack:install. However, I am having a basic problem following the tutorial. I have "4.0" selected as my version of Backpack when browsing the documentation. I therefore assume that there is a version of Backpack 4.0.x where php artisan backpack:crud tag is a valid command, where x < 23. However, in Backpack 4.0.23, php artisan backpack:crud tag fails with the following message: Command "backpack:crud" is not defined.

If the command was removed between 3.6 and 4.0.x, it needs to be listed in the Release Notes. Additionally, you need to expand the tutorial to cover the creation of the request file.

For some examples code formatting is not consistent

Also, in some places there are comments like these and they break "autoformat" like this:
image

It should behave like this:
image

I made some changes to make formatting consistent and moved some comments so that auto format on copy&paste knows how to correctly format the code (tested in PhpStorm)

Pull request: #66

[Proposal] Troubleshooting section

A place where we can:

  • direct people to the right place if they get stuck (StackOverflow, Gitter, Reddit);
  • treat each common user error in particular, and its solution (sort of a FAQ);

What is the correct way to call store and update function?

I looked backpack upgrade guide 3.6 to 4.0 and it shows store and update function have $request parameter like image 1
1
But after that i checked crud-operation-create and crud-operation-update function in doc it shows store and update function have not $request parameter like image 2 and 3.
My question is which is the correct one?
2
3

[4.1][Upgrade guide] - Add reference to the use of 'appends' in case of using an accessor

Hi,
first of all thank you very much for all your efforts and your awesome product.

I have just upgraded Backpack from version 4.0 to 4.1.

The upgrade guide is very detailed, but i had a problem with an accessor column attribute.

After I investigated for a while I found out that i had to add the accessor attribute to the $appends model's variable.

As reported in this Pedro's comment (Laravel-Backpack/CRUD#2732 (comment)) i would suggest to add some reference to the use of the following property:

    /**
     * The accessors to append to the model's array form.
     *
     * @var array
     */
    protected $appends = ['snake_case_accessor'];

In my opinion the addition could be done in the Model section.

Since the use of the $appends is not requested by default using a model accessor (but just if the accessor computed values are to be added to the array / JSON representations of the model),
it would be nice to have some reference also in the main guide.

Thanks
Luca

import button via ajax in single page article

I would like search images in storage upload and
if article title is in name file 'title-article.jpg' for example associate image automatically.

All via Ajax.
It is possibile?

For Example:
Add field button "import images" in page article.
When click button, search in storage upload, and if files exist response it in view.

Should be dark mode

When someone tries to read the document, it kinda feels hurt our eyes when reading all article in white background, so please make the dark mode for Simple & Calm UI

[4.1] Add hint to FetchOperation in documentation for InlineCreate operation / 'relationship' field type

Background

I implemented a relationship field for a Category attribute within a Product's CRUD controller. I followed the InlineCreate Operation documentation.

I expected to be able to see existing category entities in the relationship and be able to search for existing category entities. Both things did not work. The category field just stayed empty.

The browser's developer console showed me error 404s for the fetch-routes. For example, when opening the product's create/update view, the category field did not show any content, but the browser reported an error 404 for /admin/product/fetch/category (and more 404s when I continued to type in the category field's search).

The solution

I stumbled upon the fact that I needed to implement the fetch operation (which enables ajax) in my CRUD controller as documented here.

The only hint is given by the code example on InlineCreate Operation documentation page:

// for 1-n relationships (ex: category) - inside ArticleCrudController
[
    'type' => "relationship",
    'name' => 'category', // the method on your model that defines the relationship
    'ajax' => true,
    'inline_create' => true, // assumes the URL will be "/admin/category/inline/create"
]

It shows the usage of 'ajax' => true. I at first thought it was just a coincidence of this example and that I can use the InlineCreate operation without ajax as neither the requirements nor the how to use sections document the requirement to implement the fetch operation / ajax.

I suggest to improve the documentation of the InlineCreate operation.

Go through docs and rewrite so first-time Laravel users can learn Laravel & Backpack at the same time

The Problem

We seem to have more&more users who are not very accustomed to all the Laravel jargon, because it's their first/second/third Laravel project, so they haven't gone though most of the Laravel features.

Since we don't explain a lot of stuff we consider general-Laravel-knowledge, these people get stuck or wonder what this is and that is. Which must be very frustrating, leading them to think "our docs are bad".

The Solution

We should run another pass through our entire docs, reading it like it were our first/second/third Laravel project and we decided to use Backpack. That'll probably convince us we need to:

  • provide links to the Laravel docs when we use Laravel jargon (ex: accessors/mutators/request/validation/etc)
  • explain the MVC concept and the normal request lifecycle (route-middleware-controller-model-view) - a diagram would probably help a lot here
  • what else...?

Documentation Update

Bug report

In the following document we are advised to set custom views per crud as follows:
$this->crud->setCreateView('your-view');
https://backpackforlaravel.com/docs/4.1/crud-how-to#customize-views-for-each-crud-panel

What I did

Used the following:
$this->crud->setCreateView('my_create_view_name');

Folder location of view file:
resources/views/vendor/backpack/crud/my_create_view_name.blade.php

What I expected to happen

The custom view would be used for one particular crud create view

What happened

This gives a view not found error

What I've already tried to fix it

The solution is to use:
$this->crud->setCreateView('crud::my_create_view_name');

It would be useful if the documentation reflected this

CRUD Tutorial 4.0 incorrect import model

I was getting an error following the tutorial CRUD Tutorial 4.0 in a new project Model

Import for CrudTrait is incorrect Backpack\CRUD\CrudTrait;

Solution from Upgrade Guide

replace Backpack\CRUD\CrudTrait with Backpack\CRUD\app\Models\Traits\CrudTrait

Cannot create tag, a column not found

I follow the tutorial in the Getting Start. 1. Basics. And until CRUDs, I run the command mentioned.

Then I run php artisan migrate.

Afterwards, I just copy and paste the code in controller, here is my final TagCrudController.php file:

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Requests\TagRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;

/**
 * Class TagCrudController
 * @package App\Http\Controllers\Admin
 * @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
 */
class TagCrudController extends CrudController
{
    use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;

    public function setup()
    {
        $this->crud->setModel('App\Models\Tag');
        $this->crud->setRoute(config('backpack.base.route_prefix') . '/tag');
        $this->crud->setEntityNameStrings('tag', 'tags');
    }

    protected function setupListOperation()
    {
        $this->crud->setColumns(['name', 'slug']);

        // TODO: remove setFromDb() and manually define Columns, maybe Filters
        $this->crud->setFromDb();
    }

    protected function setupCreateOperation()
    {
        $this->crud->setValidation(TagRequest::class);

        $this->crud->addField([
            'name' => 'name',
            'type' => 'text',
            'label' => "Tag name"
        ]);

        $this->crud->addField([
            'name' => 'slug',
            'type' => 'text',
            'label' => "URL Segment (slug)"
        ]);

        // TODO: remove setFromDb() and manually define Fields
        $this->crud->setFromDb();
    }

    protected function setupUpdateOperation()
    {
        $this->setupCreateOperation();
    }
}

After logging in and try to add a new tag, an error prompted and said:

Illuminate\Database\QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'slug' in 'field list' (SQL: insert into `tags` (`name`, `slug`, `updated_at`, `created_at`) values (test, test, 2020-03-04 07:40:26, 2020-03-04 07:40:26))

Yes I know that the migrate file did not have slug column. However, can I assume that once I use the code in TagCrudController, the column is there?

If not, it seems that your tutorial is not updated since I did not see any step on "Creating a slug column in controller".

So, can you please tell me how to solve it? Thank you.

[4.1][WIKI] How to use image mutator inside Repeatable field

So Repeatable it's an amazing field but i had issue with image field inside it of how to save image path or even override the mutator function of it so after a simple research i was able to fix it like that.

Repeatable Field Setup
Capture d’écran 2020-06-30 à 19 15 53

            [   // repeatable
                'name'  => 'images',
                'label' => 'Images',
                'type'  => 'repeatable',
                'fields' => [
                    [
                        'name'    => 'image',
                        'type'    => 'image',
                        'label'   => 'Image'
                    ],
                    [
                        'label' => 'Big Image',
                        'name' => 'is_big',
                        'type' => 'checkbox',
                    ],
                ],
            ]

Repeatable Field Mutator
Capture d’écran 2020-06-30 à 19 06 49

    public function setImagesAttribute($value)
    {
        $images = json_decode($value, true);
        if (count($images)) {
            foreach ($images as &$jsonInfo) {
                $image = $jsonInfo['image'];
                if (Str::startsWith($image, 'data:image')) {
                    $newImage = $this->setImageMutator($image);
                    $jsonInfo['image'] = $newImage;
                }
            }
            $this->attributes['images'] = json_encode($images);
        }
        
    }

Image Setter same as documentation with some comments to serve my need
Capture d’écran 2020-06-30 à 19 12 27

    public function setImageMutator($value) {
        // or use your own disk, defined in config/filesystems.php
        $disk = 'cloud_disk';
        // destination path relative to the disk above
        $destination_path = "cloud/media/uploads";

        // if the image was erased
//        if ($value==null) {
//            // delete the image from disk
//            \Storage::disk($disk)->delete($this->{$attribute_name});
//
//            // set null in the database column
//            $this->attributes[$attribute_name] = null;
//        }

        // if a base64 was sent, store it in the db
        if (Str::startsWith($value, 'data:image'))
        {
            // 0. Make the image
            $image = \Intervention\Image\Facades\Image::make($value)->encode('jpg', 90);

            // 1. Generate a filename.
            $filename = md5($value.time()).'.jpg';

            // 2. Store the image on disk.
            \Storage::disk($disk)->put($destination_path.'/'.$filename, $image->stream());

            // 3. Delete the previous image, if there was one.
//            \Storage::disk($disk)->delete($this->{$attribute_name});

            // 4. Save the public path to the database
            // but first, remove "public/" from the path, since we're pointing to it
            // from the root folder; that way, what gets saved in the db
            // is the public URL (everything that comes after the domain name)
            $public_destination_path = Str::replaceFirst('public/', '', $destination_path);
            return $public_destination_path.'/'.$filename;
        }
    }

Images saved in database like that
Capture d’écran 2020-06-30 à 19 10 18

And also uploaded and saved to my disk correctly
Capture d’écran 2020-06-30 à 19 11 07

Hope it helps someone and hope it make sense, any suggests for improvements.

[4.1] Update callback confusion

Referring to Laravel-Backpack/CRUD#235 (comment)

Can the documentation for the update 'callback' please be improved to reflect how to properly do this? (Of course please correct me if this is indeed NOT the right way to go about this)

ExampleCrudController.php

public function update()
{
    $request = request();
    $request->request->add(['new_field' => 'New value']);
    $response = $this->traitUpdate($request);
    return $response;
}

Using the code from the documentation $this->crud->request->request->add(...) was always resulting in Cannot access protected property Backpack\CRUD\app\Library\CrudPanel\CrudPanel::$request

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.