Jump to content

ali_254

Members
  • Posts

    97
  • Joined

  • Last visited

Posts posted by ali_254

  1. Your requirements could not be resolved to an installable set of packages.

      Problem 1
        - Root composer.json requires php ^7.2 but your php version (8.1.0) does not satisfy that requirement.
      Problem 2
        - laravel/passport[v8.3.0, ..., 8.x-dev] require php ^7.2 -> your php version (8.1.0) does not satisfy that requirement.
        - Root composer.json requires laravel/passport ^8.3 -> satisfiable by laravel/passport[v8.3.0, ..., 8.x-dev].

  2. hi...

    I want when receiving information from the database , Make a change in one of the fields.

    I do not want to write the change function in the field on all models.

    I want to make changes to all the eloquent classes. (override methods).

     

    In all tables, I have a history field(created_at).

    I want to make the desired changes to this field when I receive the information

     

  3. Hi, in the kernel file, a number of arrays are defined...

        protected $middleware = [
            // \App\Http\Middleware\TrustHosts::class,
            \App\Http\Middleware\TrustProxies::class,
            \Fruitcake\Cors\HandleCors::class,
            \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
            \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
            \App\Http\Middleware\TrimStrings::class,
            \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        ];
    
        protected $middlewareGroups = [
            'web' => [
                \App\Http\Middleware\EncryptCookies::class,
                \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
                \Illuminate\Session\Middleware\StartSession::class,
                // \Illuminate\Session\Middleware\AuthenticateSession::class,
                \Illuminate\View\Middleware\ShareErrorsFromSession::class,
                \App\Http\Middleware\VerifyCsrfToken::class,
                \Illuminate\Routing\Middleware\SubstituteBindings::class,
            ],
    
    
        protected $routeMiddleware = [
            'auth' => \App\Http\Middleware\Authenticate::class,
            'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
            'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
            'can' => \Illuminate\Auth\Middleware\Authorize::class,
            'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
            'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
            'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
            'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
            'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
        ];

     

    But Laravel's document does not explain them, what is the reason?

    https://laravel.com/docs/8.x/middleware

  4. hi.

    I wrote this code and printed it:

          $category=Category::find(16);
             dd($category);

     

    The result: (The result of executing the above code , return an object of the category class.)

    App\Models\Category {#1353 ▼
      #connection: "mysql"
      #table: "categories"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      +preventsLazyLoading: false
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #escapeWhenCastingToString: false
      #attributes: array:5 [▶]
      #original: array:5 [▶]
      #changes: []
      #casts: []
      #classCastCache: []
      #attributeCastCache: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #fillable: array:2 [▶]
      #guarded: array:1 [▶]
    }

     

     

    but , When I run this code:

            $category=Category::find(16);
            $class_vars = get_object_vars($category);
            dd($class_vars);

     

     result:

    array:5 [▼
      "incrementing" => true
      "preventsLazyLoading" => false
      "exists" => true
      "wasRecentlyCreated" => false
      "timestamps" => true
    ]

     

    Which of the results, Are the real properties of category class ?
      I'm confused

  5. 7 hours ago, kicken said:

    First only returns a single item, so there's no point in putting it in a collection.

    The collection is for methods that might return several items. 

    thanks...

    collection class in laravel , Uses standard php functions? (Functions of working with arrays in php)

     Or does it use other "mechanisms"?

     

  6. hi...

    hello everybody...

    I create model and wrote this code in controller (my model name in Category):

     

          $category=Category::all();
            dd($category);

    When I use "all" method , This returns the result:

    Illuminate\Database\Eloquent\Collection {#1024 ▼
      #items: array:3 [▶]
      #escapeWhenCastingToString: false
    }

    In fact, it is the output of the Eloquent/collection class.

     

    But, when I use "first" method:

       $category=Category::first();
            dd($category);

    Returns the Models\Category class:

    App\Models\Category {#1022 ▶}

     

     

    According to Laravel documents:

    Quote

    As we have seen, Eloquent methods like all and get retrieve multiple records from the database. However, these methods don't return a plain PHP array. Instead, an instance of Illuminate\Database\Eloquent\Collection is returned.

    Our output must be from Eloquent/collection class ... But, when I use "first" method , Returns the Models\Category class.

     

    what is the reason?!!

  7. hi... i remove composer and reinstalled it...

    I get this error when try to install Laravel version 8

    https://repo.packagist.org could not be fully loaded (curl error 28 while downloading https://repo.packagist.org/packages.json: Connection timed out after 10004 milliseconds), package information was loaded from the local cache and may be out of date

    Of course, Laravel is installed and running , But this error is seen when installing Laravel

     

  8. 17 hours ago, Strider64 said:

    I'm not too sure as I haven't done it yet, but the only difference would be when you go fetch the data that instead of directly getting from PHP that you would get it from AJAX/JSON.  That way the page doesn't reload and has a more seamless appearance to the user.

     

    I want to use the pagination in CodeIgniter 4. When I use Ajax, it is not possible to use pagination....

    google

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.