mercredi 31 octobre 2018

NotFoundHttpException error on post method Laravel 5.1

I got error NotFoundHttpException below

Error

Here is my route

Route::post('/ticket/{slug?}/edit', 'TicketsController@update');

My function update on TicketController

public function update($slug, TicketFormRequest $request)
{
    $ticket = Ticket::whereSlug($slug)->firstOrFail();
    $ticket->title = $request->get('title');
    $ticket->content = $request->get('content');
    if($request->get('status') != null) {
        $ticket->status = 0; } else {
    $ticket->status = 1;
}
$ticket->save();
return redirect(action('TicketsController@edit', $ticket->slug))->with('status', 'The ticket '.$slug.' has been updated!');

}

My function edit

 public function edit($slug)
{
    $ticket = Ticket::whereSlug($slug)->firstOrFail();
    return view('tickets.edit', compact('ticket'));
}

Am I missed something? I think my routes was right, maybe my update function is wrong



via Chebli Mohamed

lundi 29 octobre 2018

Query Builder Eloquent Where clause for TimeStamp - Laravel 5.1

I have a table and search bar.

enter image description here

When user input in the search that when I grab that and query my database.

This is what I got

public function getLogsFromDb($q = null) {

    if (Input::get('q') != '') {
        $q = Input::get('q');
    }
    $perPage = 25;

    if ($q != '') {

        $logs = DB::table('fortinet_logs')
            ->orWhere('account_id', 'like', '%'.$q.'%')
            ->orWhere('cpe_mac', 'like', '%'.$q.'%')
            ->orWhere('p_hns_id', 'like', '%'.$q.'%')
            ->orWhere('g_hns_id', 'like', '%'.$q.'%')
            ->orWhere('data', 'like', '%'.$q.'%')
            ->orWhere('created_at', 'like', '%'.$q.'%') <----🐞
            ->orderBy('updated_at', 'desc')->paginate($perPage) 
            ->setPath('');


            //dd($logs);

        $logs->appends(['q' => $q]);

    } else {

        $logs = DB::table('fortinet_logs')
            ->orderBy('created_at', 'desc')->paginate($perPage)
            ->setPath('');
    }

    return view('telenet.views.wizard.logTable', get_defined_vars());

}


Result

In the network tab, I kept getting

Undefined function: 7 ERROR: operator does not exist: timestamp without time zone ~~ unknown

enter image description here


Questions

How would one go about and debug this further ?


I'm open to any suggestions at this moment.

Any hints/suggestions / helps on this be will be much appreciated!



via Chebli Mohamed

samedi 27 octobre 2018

Laravel Model Factory Error: Trying to get property of non-object

I'm trying to use a model factory to seed my database, but when I run it I get the error:

Trying to get property 'id' of non-object

Here is my code:

// TasksTableSeeder.php

factory(pams\Task::class, '2000', rand(1, 30))->create();

// ModelFactory.php

$factory->defineAs(pams\Task::class, '2000', function (Faker\Generator $faker) {
static $task_number = 01;
return [
    'task_number' => $task_number++,
    'ata_code' => '52-00-00',
    'time_estimate' => $faker->randomFloat($nbMaxDecimals = 2, $min = 0.25, $max = 50),
    'work_order_id' => '2000',
    'description' => $faker->text($maxNbChars = 75),
    'action' => '',
    'duplicate' => '0',
    'certified_by' => '1',
    'certified_date' => '2015-11-08',
    'status' => '1',
    'created_by' => '1',
    'modified_by' => '1',
    'created_at' => Carbon\Carbon::now()->format('Y-m-d H:i:s'),
    'updated_at' => Carbon\Carbon::now()->format('Y-m-d H:i:s'),
    ];
});

I've tried removing all variables from the model factory and using constants, but that doesn't fix it. I've tried pulling the data from the ModelFactory.php and put it directly into the TasksTableSeeder.php and it does work, however I was using constants and no variables.

I cannot for the life of me figure out what 'id' it's talking about.

I'm running Laravel v5.1



via Chebli Mohamed

jeudi 25 octobre 2018

how to use this php sql on laravel??? (dynamic form field)

<?php
$fields = array(
 array(
 'meta_id' => 'name',
 'display_name' => 'Name'
 ),
 array(
 'meta_id' => 'address',
 'display_name' => 'Address'
 ),
 array(
 'meta_id' => 'cps_name',
 'display_name' => 'CSP Name'
 )
);


$tables = array();
$query_fields = array();
$joins = array();
$fcount = 1;


array_push($query_fields, "reports.*");

foreach ($fields as $key => $value) {
 $table_name = "tables" . $fcount++;
 array_push($query_fields, $table_name.".".$value['meta_id']." AS ".$value['display_name']);

 array_push($joins, "INNER JOIN reports_meta_values ".$table_name." ON reports.id = ".$table_name.".report_id AND ".$table_name.".meta_id='".$value['meta_id']."'");
}


$final_sql = "SELECT " .implode(",", $query_fields) . " FROM reports " . implode(" ", $joins). " WHERE 1";

echo "$final_sql";

?>



via Chebli Mohamed

Set up Laravel project to work with multiple Domain Name

enter image description here

I have successfully configured multiple domains to point to my Laravel 5.1 project

<Virtualhost *:80>
  VirtualDocumentRoot "/Users/Sites/project/public"
  ServerName app.com
  UseCanonicalName Off
</Virtualhost>

<Virtualhost *:80>
  VirtualDocumentRoot "/Users/Sites/project/public"
  ServerName app2.com
  UseCanonicalName Off
</Virtualhost>

<Virtualhost *:80>
  VirtualDocumentRoot "/Users/Sites/project/public"
  ServerName app3.com
  UseCanonicalName Off
</Virtualhost>

When I go to

app.com app2.com app3.com

any of them will point to my project and load the log-in screen.


Issue

When I login, regardless when I am from, I kept redirecting my users to

app.com/dashboard


Goal

My goal is, any request from

app.com  --> log-in --> redirect to --> app.com/dashobard
app2.com --> log-in --> redirect to --> app2.com/dashobard
app3.com --> log-in --> redirect to --> app3.com/dashobard


Questions

How would one go about and do this on a Laravel project ?

Is this something that I can do on the application layer or web server ?


I'm open to any suggestions at this moment.

Any hints/suggestions / helps on this be will be much appreciated!



via Chebli Mohamed

How to insert in a translatable field?

Using Lumen 5.1, I'd like to know how to to CRUD on a translatable field, in my case it's name.

This is migration file

class CreateDomainHolidays extends Migration
{

    protected $table = 'domain_holidays';
    protected $app_table = true;

    public function up()

    {
        Schema::create($this->getTable(), function (Blueprint $table) {
            $table->increments('id');

            $table->integer('domain_id')->unsigned()->nullable();
            $table->foreign('domain_id')->references('id')
                ->on(self::getTableName('domains'))->onDelete('cascade');
            $table->string('name')->nullable()->default('')->translatable = true;
            $table->dateTime('start_date');
            $table->dateTime('end_date');
            $table->tinyInteger('half_day_start')->default(0);
            $table->tinyInteger('half_day_end')->default(0);
            $this->parenttable = $table;

        });
        $this->createTableWithTranslation($this->parenttable);

    }

    public function down()
    {
        $this->dropTranslationTable($this->getTable());
        Schema::drop($this->getTable());
    }
}

This is my model

 class Holiday extends BaseModel
    {
        protected $table = 'domain_holidays';
        protected $app_table = true;
        public $timestamps = false;

        protected $translation = true;
        public function translations()
        {
            return $this->hasMany('App\Models\General\HolidayTranslations', 'parent_id');
        }

    }

    class HolidayTranslations extends BaseTranslationModel
    {
        protected $table = 'domain_holidays_i18n';
        protected $primaryKey = 'translation_id';
    }
}

domain_holidays contains

id
domain_id
start_date
end_date
half_day_start
half_day_end

domain_holidays_i18n contains

translation_id
parent_id
lang
name

Something like this is not working

public static function setHoliday($domainId, $name, $startDate, $endDate, $halfDayStart, $halfDayEnd)
{
    Holiday::unguard();
    return Holiday::create([
        'domain_id' => $domainId,
        'name' => $name,
        'start_date' => $startDate,
        'end_date' => $endDate,
        'half_day_start' => $halfDayStart,
        'half_day_end' => $halfDayEnd
    ]);
}

Postman would return an error

SQLSTATE[42S22]: Column not found: 1054 Unknown column &#039;name&#039; in &#039;field list&#039;



via Chebli Mohamed

mercredi 24 octobre 2018

Laravel Data change when i pass it from Controller To view

i have relations path has many tags and tags have many tasks and tasks have many tags so task may have one or more tag . My Controller return tasks that have 1 tag only and is working fine

public function task(){

 $Tasks= Path::with(['pathtags' => function ($q) {
  $q->with(['Tasks'=>function($q) {
  $q->has('tasktags', '=' , 1)
 ->with('tasktags'); }]); 
 }])->first();

  return $Tasks;
}

but When I return $Tasks in view I get all tasks in the database

i tried

  return view('task', ['Tasks' => $Tasks);
  return view('box',compact('Tasks'));

but still get all tasks not one that have 1 tag



via Chebli Mohamed

mardi 23 octobre 2018

Laravel Assets Point to Localhost/public instead of localhost/project/public

I recently used git to clone a Laravel 5.1 project from a repository to my local environment. I am using XAMPP, so I placed the project under C:/xampp/htdocs and can access it from localhost/project/public.

I updated the APP_URL variable in the.env file to point to "http://localhost/project".

I also updated the url value in config/app.php to:

'url' => env('APP_URL', 'http://localhost/project')

Right now, the both scripts resolve as http://localhost/public/assets/js/test.js:

I removed "/public" (also "public", just tetsing things) and replaced with so that now the call looks like the following and the script resolved just fine:

<script src="/assets/js/test.js"></script>

However, elixir is also being used:

<script src="."></script>

The page is not loading correctly; an Ajax call that errors out because the URL is is trying to reach is localhost/public/someotherfolder/details?=12345).

The above script seems to be the source of that AJAX call; if I comment it out, then the call doesn't run.

I checked the rev-manifest.json and it specifies "js/app.js". If I try to changed the script call to I get a 404 error. If I try add the path in the elixir call, I get a "file is not defined in manifest". Changing the manifest to use the whole path seems to defeat the purpose.

How can I solve this issue? It seems like I am missing an important step to let my application resolve without using the full path?



via Chebli Mohamed

get tasks where all task tags is in path tags

My code returns tasks where one of Task Tags name ->(tasktags) is in Path Tags->$TagArray .

I want to get Tasks where all Task Tags (tasktags) are in Path Tags array ->$TagArray.

$posts4 = Path::with(['pathtags' => function ($q) use ($TagArray) {
    $q->with(['Tasks'=>function($q) use ($TagArray) { 
        $q->has('tasktags', '=' , 2)->whereHas('tasktags', function ($query) use 
            ($TagArray) {
            $query->whereIn('name',$TagArray);

        })->with('tasktags');
    }]);
}])->first()



via Chebli Mohamed

dimanche 21 octobre 2018

Parsing html, grabbing nodeValue problem with DOMdocument

Trying to parse html page, but having some trouble at grabbing nodeValue's of dt and dd tags.

$outlineUrl = "http://www.sumitomo-rd-mansion.jp/kansai/higashi_umeda/detail.cgi";
foreach ($outlineUrl as $results) {
       $html = file_get_contents($results);
       $DOMParser = new \DOMDocument();
       $DOMParser->loadHTML($html)           

   foreach ($DOMParser->getElementsByTagName('dl') as $tr) {
             $property = trim($tr->getElementsByTagName('dt')[0]->nodeValue);
             $value = trim($tr->getElementsByTagName('dd')[0]->nodeValue);
   }

with this I can't grab the dl's and dt's nodeValue. Is my foreach loops wrong or something? Thanks for helping me out!



via Chebli Mohamed

jeudi 18 octobre 2018

Laravel - Internal Server Error and Forbiden Access

I use cPanel tranfer tool to copy the website from a server to another server, but after that, I got Internal Server Error...

To solve that problem I run the command:

sudo chown -R perica:perica /home/perica/public_html/

after that:

sudo find /home/perica -type f -exec chmod 664 {} \; 

sudo find /home/perica -type d -exec chmod 775 {} \;

but I got again the same error.

I also try to sudo find /home/perica -type f -exec chmod 700 {} \; but then I got error

 Forbidden
You don't have permission to access /admin on this server.
Server unable to read htaccess file, denying access to be safe

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Also, my storage folder and bootstrap permission is 777.

What is the problem? I spend 2 days to solve this problem but no success! Please HELP!

UPDATE: I delete .htaccess file and now I see the Laravel folder structure but when I navigate a browser to domain.com/public folder again I got error.



via Chebli Mohamed

DB data's ID and paging the data differently with Laravel

I've table in DB which has estate datas. Now I'am retrieving those datas on the main blade. But also I want to retrieve those data separatly by their ID on another page. Do I need to create html table in a blade each of every ID? Or can I make it in just one blade? Or any idea?

Thank you!



via Chebli Mohamed

mardi 16 octobre 2018

My pagination not going next page, returns main page

I do pagination to table. But when I click the numbers just return the main page and Url shows like this: http://example/?q=?=大阪&page=2

This how I calling the links for pagination on view.blade



And this is the controller:

$q = $request->q;
        if ($q !== null && trim($q) !== ""){//here

            $estates = \DB::table('allestates')
                ->where("building_name","LIKE", "%" . $q . "%")
                ->orWhere("address","LIKE", "%" . $q . "%")
                ->orWhere("company_name","LIKE", "%" . $q . "%")
                ->orWhere("region","LIKE", "%" . $q . "%")
                ->orderBy('price')->get();


            $showPerPage = 10;

            $perPagedData = $estates
                ->slice((request()->get('page')) * $showPerPage, $showPerPage)
                ->all();

            $estates = new \Illuminate\Pagination\LengthAwarePaginator($perPagedData, count($estates), $showPerPage, request()
                ->get('page'));


            if(count($estates) > 0){
                return view("search", compact('estates'))->withQuery($q);
            }

        }

What am I missing here? My guess is it couldn't find the next page? But why?



via Chebli Mohamed

lundi 15 octobre 2018

Query a list of value of a specific column - Laravel

I'm trying to query a list as an array directly out of a table of my database without having to create another foreach loop and construct one myself.


I try

return Response::json(Skill::select('name')->get());

I get

[{"name":"Vagrant"},{"name":"Docker"},{"name":"Gulp"},{"name":"Heroku"},{"name":"RequireJS"},{"name":"AngularJS"},{"name":"Composer "},{"name":"NPM"},{"name":"MySQL"},{"name":"Sublime Text"},{"name":"Laravel"},{"name":"PyCharm"},{"name":"Mac OS X"},{"name":"Windows"},{"name":"Ubuntu"},{"name":"Cent OS"},{"name":"Photoshop"},{"name":"Illustrator"},{"name":"MobaXTerm"},{"name":"Terminal"},{"name":"iMovie"},{"name":"Final Cut"},{"name":"GitHub"},{"name":"BitBucket"},{"name":"Selenium"},{"name":"Python"},{"name":"Bower"},{"name":"Sass"},{"name":"Digital Ocean"},{"name":"Linode"},{"name":"Siteground"},{"name":"Go Daddy"},{"name":"Shopify"},{"name":"Facebook"},{"name":"Twitter"},{"name":"Salesforce"},{"name":"OAuth 2.0"},{"name":"SAML 2.0"},{"name":"OpenID Connect"},{"name":"PostgreSQL"},{"name":"Bash"},{"name":"PHP"},{"name":"Google Map"},{"name":"Google Translation"},{"name":"Instagram"},{"name":"LESS"},{"name":"Geolocation API"},{"name":"Xcode"},{"name":"Atom"},{"name":"Webpack"},{"name":"AWS Console"},{"name":"Secure Shell"},{"name":"Node"},{"name":"Yarn"},{"name":"Pod"},{"name":"EC2"},{"name":"Amazon ECS"},{"name":"S3"},{"name":"Amazon RDS"},{"name":"Camtasia"},{"name":"Core Data"},{"name":"Realm"},{"name":"VS Code"},{"name":"TextMate"},{"name":"TextWrangler"},{"name":"Laravel Elixir"},{"name":"Virtual Machine"},{"name":"Open  Stack"},{"name":"Redis"},{"name":"Local Storage"},{"name":"Protractor"},{"name":"Jest"},{"name":"Mocha"},{"name":"Chai"},{"name":"SinonJS"},{"name":"AWS"},{"name":"HTML"},{"name":"CSS"},{"name":"Javascript"},{"name":"Sketch"},{"name":"iOS"},{"name":"Express"},{"name":"Angular"},{"name":"React Native"},{"name":"jQuery"},{"name":"Nginx"},{"name":"Apache"},{"name":"PayPal"},{"name":"Square "},{"name":"Disqus"},{"name":"YouTube"},{"name":"Swagger"},{"name":"GitLab"},{"name":"Amazon ECR "},{"name":"Jira"},{"name":"Trello "},{"name":"Evernote "},{"name":"Confluence "},{"name":"Word"},{"name":"CodeBox"},{"name":"Markdown"},{"name":"Noteability"},{"name":"Kamar"},{"name":"Jasmine"},{"name":"Swift"},{"name":"Coda"},{"name":"Postman"},{"name":"Wireshark"},{"name":"Transmit"},{"name":"WinSCP"},{"name":"Navicat Premium"},{"name":"Kaleidoscope"},{"name":"Mind Note "},{"name":"Divvy"},{"name":"Duet"},{"name":"Draw.io"},{"name":"Google Draw"},{"name":"VMWare Fusion "},{"name":"Virtualbox"},{"name":"QuickBooks"},{"name":"Chat.io"},{"name":"FusionCharts"},{"name":"Google Chart"},{"name":"J Player"},{"name":"CKEditor"}]

I was trying to get these

["Vagrant","Docker","Gulp","Heroku","RequireJS","AngularJS","Composer ","NPM","MySQL","Sublime Text","Laravel","PyCharm","Mac OS X","Windows","Ubuntu","Cent OS","Photoshop","Illustrator","MobaXTerm","Terminal","iMovie","Final Cut","GitHub","BitBucket","Selenium","Python","Bower","Sass","Digital Ocean","Linode","Siteground","Go Daddy","Shopify","Facebook","Twitter","Salesforce","OAuth 2.0","SAML 2.0","OpenID Connect","PostgreSQL","Bash","PHP","Google Map","Google Translation","Instagram","LESS","Geolocation API","Xcode","Atom","Webpack","AWS Console","Secure Shell","Node","Yarn","Pod","EC2","Amazon ECS","S3","Amazon RDS","Camtasia","Core Data","Realm","VS Code","TextMate","TextWrangler","Laravel Elixir","Virtual Machine","Open  Stack","Redis","LocalStorage","Protractor","Jest","Mocha","Chai","SinonJS","AWS","HTML","CSS","Javascript","Sketch","iOS","Express","Angular","React Native","jQuery","Nginx","Apache","PayPal","Square ","Disqus","YouTube","Swagger","GitLab","Amazon ECR ","Jira","Trello ","Evernote ","Confluence ","Word","CodeBox","Markdown","Noteability","Kamar","Jasmine","Swift","Coda","Postman","Wireshark","Transmit","WinSCP","Navicat Premium","Kaleidoscope","Mind Note ","Divvy","Duet","Draw.io","Google Draw","VMWare Fusion ","Virtualbox","QuickBooks","Chat.io","FusionCharts","Google Chart","J Player","CKEditor"]


Questions

How would one go about and debug this further ?


I'm open to any suggestions at this moment.

Any hints/suggestions / helps on this be will be much appreciated!



via Chebli Mohamed

jeudi 11 octobre 2018

DOKU Payment Gateway for PHP Integration?

I want to ask about how to make doku payment integration to my website (laravel). Now I'm already have all the credentials needed(mallid, merchant) but i dont know how to start, if there's any refference it will help me, thank you.



via Chebli Mohamed

mardi 9 octobre 2018

Select top from group

I have model Message:

 protected $fillable = [
        'id','text','girl_id','date' ];

How to choose the last message by date for each girl_id?

My code:

   $messages=Message::select(['id','text','girl_id','date'])
                    ->groupBY('girl_id')
                    ->orderBY('date')
                    ->take(1)
                    ->get();



via Chebli Mohamed

lundi 8 octobre 2018

Article, Comment and User relationship in Laravel 5.1

I made a blog where you can CRUD articles and post comments. Everything is fine and working good.

I just want to make Laravel to do the magic when the User posts a comment to an article and instead of hard-coding article_id and user_id.

Comment::create([
    'body' => request('body'),
    'article_id' => $article->id,
    'user_id' => Auth::User()->id]
);

Is it possible to use Laravel's Eloquent relationships to chain up some functions/methods and simplify it a little bit?



via Chebli Mohamed

eager load model ids only

Using Laravel 5.1, I have deeply connected and nested models for my HTML5 game. When the player logs in, it loads their profiles.

Each profile has m:m completed quests, m:m completed tasks, m:m completed minigames, etc.

The quests/tasks/minigames are belongsTo relationship, i.e., Task belongsTo Quest, Minigame belongsTo Task, etc.

Eager loading these on the user->profile then takes a ton of time.

What I need to do instead then is eager load only the IDs of tasks, minigames, etc for the profile. I tried this via $appends:

class Profile extends BaseModel
{
    protected $with = ['game', 'quests'];

    protected $appends = ['task_ids'];

    public function getTaskIdsAttribute()
    {
        return $this->tasks->pluck('task_id');
    }

Still, this loads the models and an array of two null task Id values (The loaded task models eager load with their related children too.):

  • task_ids is an array with two null values.

  • tasks is an array with two eager loads Task models.

enter image description here

I need to speed up login so how can I load IDs only without the rest of the attributes?



via Chebli Mohamed

dimanche 7 octobre 2018

laravel update Has Many Relation for items in invoice

I'm trying to update items in the invoice, and I need and the problem when deleting item or add an item if I delete all item it updates I need help, please

invoice table

  • id
  • invoice _no
  • date
  • sub_total
  • discount
  • total

items table

  • id

  • item_code

  • item_desc

  • unit_price

invoice_items table

  • invoice_id

  • item_id

  • unit_price

  • qty

invoice model

public function items()
    {
        return $this->hasMany(InvoiceProduct::class, 'invoice_id');
    }

my controller update

$invoice = Invoice::findOrFail($id);

        $items = [];
        $itemIds = [];
        $subTotal = 0;

        foreach($request->items as $item) {
            if(isset($item['id'])) {
                InvoiceProduct::where('invoice_id', $invoice->id)
                    ->Where('id', $item['id'])
                    ->update($item);

                $itemIds[] = $item['id'];
               $item ='please re add items';
            } else {
                $items[] = new InvoiceProduct($item);
            }

            $subTotal += $item['unit_price'] * $item['qty'];
        }


        $data = $request->except('items');
        $data['sub_total'] = $subTotal;
        $data['total'] = $data['sub_total'] - $request->discount;

        $invoice->update($data);

        InvoiceProduct::whereNotIn('id', $itemIds)
            ->where('invoice_id', $invoice->id)
            ->delete();

        if(count($items)) {
            $invoice->items()->saveMany($items);
        }
 return response()
            ->json(['saved' => true, 'id' => $invoice->id]);
    }



via Chebli Mohamed

vendredi 5 octobre 2018

no hint path laravel

Hey guys it's my first time deploying my work online.. I have some couple of routes that work perfectly on my local but when I'm on the server I get this error..

View [frontoffice.Sondage.list_sondage] not found

I'm using l5-modular package for modules

it's something like :

app/
└── Modules/
    └── Poll/
        ├── Controllers/
        │   └── PollController.php
        ├── Models/
        │   └── Poll.php
        ├── Views/
        |     └── frontoffice
        │     └── Sondage
        |      └── list_sondage.blade.php
        ├── Translations/
        │   └── en/
        │       └── example.php
        ├── routes
        │   ├── api.php
        │   └── web.php
        └── helper.php

I'm returning this view :

 return view('Poll::frontoffice.Sondage.list_sondage',compact('resultats_groupe','config'));

what can be this error coming from?



via Chebli Mohamed

mercredi 3 octobre 2018

How to Searching between min and max prices in Laravel

I know in mysql query it is something like this

SELECT id 
FROM listings 
WHERE id  IN (
  SELECT id
  FROM listings
  WHERE price between 200 and 500
);

in laravel query I tired

Listing::select('listings.*')
                 ->whereBetween('price', [200, 500])
                 ->groupBy('listings.id')
                 ->orderBy('listings.id', 'desc')
                 ->paginate(1000);

did I wrong somewhere ? It just show only 1 result ?

thank you for your helps!



via Chebli Mohamed

mardi 2 octobre 2018

Autocomplete or Live search in Laravel/app.php

I am planning to develop a database. It's not started yet but I want to know whether it's possible to include autocomplete or Live search options in app.php.

Any ideas regarding this is welcome.

Thanks.



via Chebli Mohamed

Resolve index issue in php laravel [duplicate]

I'm trying to display download links(pdf) on my page but I'm getting an index error

Undefined offset: 6 (View: C:\xampp\htdocs\bluepenlabs\fta\app\Modules\Fta\views\frontoffice\Fta\voir-docs.blade.php)

This is my controller :

 public function docs(){
        $docs = Document::all();
        return view("Fta::frontoffice.Fta.voir-docs",compact('docs'));
 }

this is the view

 <?php
       if(file_exists(public_path('frontoffice/fichiers/docs'))){
         $files = File::allFiles(public_path('/frontoffice/fichiers/docs/'));
       }
       if(!empty($docs)){
               foreach ($docs as $doc){
                     //$fichier = explode("/", $file);
                     $fichier = explode("-", $doc['file']);
                    $ext = explode(".", $fichier[6]);

  ?>
        <span style="font-size: x-large;color: royalblue;"></span>
         <br><br>
         <p style="color: black">{!!  $doc->description !!}</p>
         <a href="/frontoffice/fichiers/docs//" download style="font-size: x-large"></a>

          @if($ext[1]== "pdf")
                <div class="box"><iframe src="/frontoffice/fichiers/docs//" width = "300px" height = "300px"></iframe></div>
           @endif  
           <br>   
           <medium> Crée le :  <br>Modifier le : </medium>
            <hr>
             <?php }
                   }
                  ?>

I tried to dd($fichier) it gives me this :

enter image description here



via Chebli Mohamed

Left Joining with two table does not work properly. It shows error for using max function

$student_classtest_for_sba_mark=DB::table('tbl_student_admission') 
                ->leftJoin('tbl_student_subject_mark', 'tbl_student_admission.student_id', '=', 'tbl_student_subject_mark.student_id')
                ->selectRaw('tbl_student_subject_mark.*, tbl_student_admission.student_id,  tbl_student_admission.student_full_name_english, tbl_student_admission.class, tbl_student_admission.section, tbl_student_admission.roll_no, sum(total_obtained_mark) as total_mark, sum(grade_point) as total_gread_point,
                max(if(tbl_student_subject_mark.exam_title = "'.$exam_list[0]->exam_id.'" , total_obtained_mark, null)) E1,                                               
                max(if(tbl_student_subject_mark.result_status = "Fail" , result_status, null)) result_status')                
                ->where('tbl_student_subject_mark.academic_year', $academic_year)
                ->where('tbl_student_admission.class', $class)                
                ->where('tbl_student_admission.section', $section)                
                ->where('tbl_student_subject_mark.subject_name', $subject_name)
                ->groupBy('tbl_student_admission.student_id')
                ->get(); 

Display the Error:

SQLSTATE[42000]: Syntax error or access violation: 1055 'db_smsfinal1user.tbl_student_subject_mark.student_subject_mark_id' isn't in GROUP BY



via Chebli Mohamed